]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm backup: Fixed unnecessary mailbox deletion.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 20 May 2016 12:55:52 +0000 (15:55 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 20 May 2016 12:55:52 +0000 (15:55 +0300)
Broken by 79490ec1a. The idea is to delete the mailbox early to avoid
unnecessary work, but we deleted it too early. If the last mail(s) were
deleted instead of just expunging them we deleted the whole mailbox.

src/doveadm/dsync/dsync-mailbox-import.c

index 148c8dd5b7f3461f451f55a6b7d612e37975a56a..4bcbc2eb12e0aa3e133966b1c014284da66d68cd 100644 (file)
@@ -783,9 +783,10 @@ static bool dsync_mailbox_try_save_cur(struct dsync_mailbox_importer *importer,
                /* add a record for local mail */
                i_assert(importer->cur_mail != NULL);
                if (importer->revert_local_changes) {
-                       if (save_change == NULL) {
+                       if (save_change == NULL &&
+                           importer->cur_mail->uid >= importer->remote_uid_next) {
                                dsync_mailbox_revert_existing_uid(importer, importer->cur_mail->uid,
-                                       t_strdup_printf("highest than remote's UIDs (remote UIDNEXT=%u)", importer->remote_uid_next));
+                                       t_strdup_printf("higher than remote's UIDs (remote UIDNEXT=%u)", importer->remote_uid_next));
                                return TRUE;
                        }
                        mail_expunge(importer->cur_mail);