From: Josef 'Jeff' Sipek Date: Thu, 24 Jun 2021 16:56:05 +0000 (-0400) Subject: virtual: Expunge old emails if backend box uidvalidity changed X-Git-Tag: 2.3.17~396 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a7c7869c7ecd7025ce684b04b67a7f48623ca09;p=thirdparty%2Fdovecot%2Fcore.git virtual: Expunge old emails if backend box uidvalidity changed --- diff --git a/src/plugins/virtual/virtual-storage.h b/src/plugins/virtual/virtual-storage.h index 8a82a4c6c0..6307bcd92e 100644 --- a/src/plugins/virtual/virtual-storage.h +++ b/src/plugins/virtual/virtual-storage.h @@ -117,6 +117,7 @@ struct virtual_backend_box { bool search_args_initialized:1; bool deleted:1; bool notify_changes_started:1; /* if the box was opened for notify_changes */ + bool first_sync:1; /* if this is the first sync after bbox was (re-)created */ }; ARRAY_DEFINE_TYPE(virtual_backend_box, struct virtual_backend_box *); diff --git a/src/plugins/virtual/virtual-sync.c b/src/plugins/virtual/virtual-sync.c index ae66bb8151..c1b0a4daee 100644 --- a/src/plugins/virtual/virtual-sync.c +++ b/src/plugins/virtual/virtual-sync.c @@ -1263,6 +1263,7 @@ static int virtual_sync_backend_box(struct virtual_sync_context *ctx, if (status.uidvalidity != bbox->sync_uid_validity) { /* UID validity changed since last sync (or this is the first sync), do a full search */ + bbox->first_sync = TRUE; ret = virtual_sync_backend_box_init(bbox); } else { /* build the initial search using the saved modseq. */ @@ -1328,7 +1329,7 @@ static void virtual_sync_backend_map_uids(struct virtual_sync_context *ctx) } bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id); - if (bbox == NULL) { + if (bbox == NULL || bbox->first_sync) { /* the entire mailbox is lost */ mail_index_expunge(ctx->trans, vseq); continue; @@ -1385,6 +1386,8 @@ static void virtual_sync_new_backend_boxes(struct virtual_sync_context *ctx) i_zero(&add_rec); bboxes = array_get(&ctx->mbox->backend_boxes, &count); for (i = 0; i < count; i++) { + bboxes[i]->first_sync = FALSE; /* this is the end of the sync */ + if (bboxes[i]->sync_seen) continue;