dovecot-1.1: mbox-snarf plugin: If copying failed due to out of ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Dec 14 08:36:24 EET 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/f9a000ee400d
changeset: 8048:f9a000ee400d
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Dec 14 08:36:10 2008 +0200
description:
mbox-snarf plugin: If copying failed due to out of disk space, don't rollback the entire move.

diffstat:

1 file changed, 9 insertions(+), 4 deletions(-)
src/plugins/mbox-snarf/mbox-snarf-plugin.c |   13 +++++++++----

diffs (31 lines):

diff -r d29567476541 -r f9a000ee400d src/plugins/mbox-snarf/mbox-snarf-plugin.c
--- a/src/plugins/mbox-snarf/mbox-snarf-plugin.c	Sun Dec 14 04:57:11 2008 +0200
+++ b/src/plugins/mbox-snarf/mbox-snarf-plugin.c	Sun Dec 14 08:36:10 2008 +0200
@@ -41,6 +41,7 @@ static int mbox_snarf(struct mailbox *sr
 	struct mail_search_context *search_ctx;
         struct mailbox_transaction_context *src_trans, *dest_trans;
 	struct mail *mail;
+	enum mail_error error;
 	int ret;
 
 	if (mailbox_sync(srcbox, MAILBOX_SYNC_FLAG_FULL_READ, 0, NULL) < 0)
@@ -60,11 +61,15 @@ static int mbox_snarf(struct mailbox *sr
 		if (mail->expunged)
 			continue;
 
-		if (mailbox_copy(dest_trans, mail, 0, NULL, NULL) < 0) {
-			if (!mail->expunged) {
+		if (mailbox_copy(dest_trans, mail, 0, NULL, NULL) < 0 &&
+		    !mail->expunged) {
+			(void)mail_storage_get_last_error(destbox->storage,
+							  &error);
+			/* if we failed because of out of disk space, just
+			   move those messages we managed to move so far. */
+			if (error != MAIL_ERROR_NOSPACE)
 				ret = -1;
-				break;
-			}
+			break;
 		}
 		mail_expunge(mail);
 	}


More information about the dovecot-cvs mailing list