dovecot-2.2: dsync backup: Old unwanted messages weren't deleted...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jan 21 17:57:30 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/940414cea18d
changeset: 15661:940414cea18d
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jan 21 17:56:36 2013 +0200
description:
dsync backup: Old unwanted messages weren't deleted as they should have.

diffstat:

 src/doveadm/dsync/dsync-mailbox-import.c |  21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diffs (84 lines):

diff -r 22a1f4cfe9fb -r 940414cea18d src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Mon Jan 21 17:45:18 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Mon Jan 21 17:56:36 2013 +0200
@@ -76,7 +76,7 @@
 	unsigned int debug:1;
 	unsigned int last_common_uid_found:1;
 	unsigned int cur_uid_has_change:1;
-	unsigned int cur_mail_saved:1;
+	unsigned int cur_mail_skip:1;
 	unsigned int local_expunged_guids_set:1;
 	unsigned int new_uids_assigned:1;
 	unsigned int want_mail_requests:1;
@@ -105,7 +105,7 @@
 	if (mailbox_search_next(importer->search_ctx, &importer->cur_mail))
 		importer->next_local_seq = importer->cur_mail->seq;
 	/* this flag causes cur_guid to be looked up later */
-	importer->cur_mail_saved = TRUE;
+	importer->cur_mail_skip = TRUE;
 }
 
 struct dsync_mailbox_importer *
@@ -212,7 +212,7 @@
 					    importer->cur_mail->uid);
 		}
 
-		importer->cur_mail_saved = FALSE;
+		importer->cur_mail_skip = FALSE;
 		if (!mailbox_search_next(importer->search_ctx,
 					 &importer->cur_mail)) {
 			importer->cur_mail = NULL;
@@ -335,12 +335,17 @@
 		m2.uid = save_change->uid;
 	}
 
-	newmail = p_new(importer->pool, struct importer_new_mail, 1);
-
 	diff = importer_mail_cmp(&m1, &m2);
 	if (diff < 0) {
 		/* add a record for local mail */
 		i_assert(importer->cur_mail != NULL);
+		if (importer->revert_local_changes) {
+			mail_expunge(importer->cur_mail);
+			importer->cur_mail_skip = TRUE;
+			importer->next_local_seq++;
+			return FALSE;
+		}
+		newmail = p_new(importer->pool, struct importer_new_mail, 1);
 		newmail->guid = p_strdup(importer->pool, importer->cur_guid);
 		newmail->uid = importer->cur_mail->uid;
 		newmail->uid_in_local = TRUE;
@@ -349,6 +354,7 @@
 		remote_saved = FALSE;
 	} else if (diff > 0) {
 		i_assert(save_change != NULL);
+		newmail = p_new(importer->pool, struct importer_new_mail, 1);
 		newmail->guid = save_change->guid;
 		newmail->uid = save_change->uid;
 		newmail->uid_in_local = FALSE;
@@ -359,6 +365,7 @@
 		/* identical */
 		i_assert(importer->cur_mail != NULL);
 		i_assert(save_change != NULL);
+		newmail = p_new(importer->pool, struct importer_new_mail, 1);
 		newmail->guid = save_change->guid;
 		newmail->uid = importer->cur_mail->uid;
 		newmail->uid_in_local = TRUE;
@@ -368,7 +375,7 @@
 	}
 
 	if (newmail->uid_in_local) {
-		importer->cur_mail_saved = TRUE;
+		importer->cur_mail_skip = TRUE;
 		importer->next_local_seq++;
 	} else {
 		/* NOTE: assumes save_change is allocated from importer pool */
@@ -384,7 +391,7 @@
 dsync_mailbox_try_save(struct dsync_mailbox_importer *importer,
 		       struct dsync_mail_change *save_change)
 {
-	if (importer->cur_mail_saved) {
+	if (importer->cur_mail_skip) {
 		if (!importer_next_mail(importer, 0) && save_change == NULL)
 			return FALSE;
 	}


More information about the dovecot-cvs mailing list