]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
virtual: Expunge old emails if backend box uidvalidity changed
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Thu, 24 Jun 2021 16:56:05 +0000 (12:56 -0400)
committerjeff.sipek <jeff.sipek@open-xchange.com>
Thu, 1 Jul 2021 12:32:34 +0000 (12:32 +0000)
src/plugins/virtual/virtual-storage.h
src/plugins/virtual/virtual-sync.c

index 8a82a4c6c04c0b72b24b2555298664f5e3a6dbe6..6307bcd92ebd20234fe4e156aa033e25651bb5b3 100644 (file)
@@ -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 *);
 
index ae66bb8151b2b67829985bf4152dfb79067cf9f9..c1b0a4daeef116ccf0bd1fbb581c7fded7e20b5e 100644 (file)
@@ -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;