If the same file was opened as the raw mailbox multiple times, the previous
mail_index was cached by mail-index-alloc-cache. Opening it the second time
already contained a mail in the index, so trying to add another one logged
an error:
Error: Log synchronization error at seq=1,offset=256 for (in-memory index): Append with UID 1, but next_uid = 2
MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY |
MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
+ if (mail_index_view_get_messages_count(mbox->box.view) > 0) {
+ /* already-synced index was opened via
+ mail-index-alloc-cache. */
+ return 0;
+ }
+
ret = mail_index_sync_begin(mbox->box.index, &index_sync_ctx,
&sync_view, &trans, sync_flags);
if (ret <= 0) {