]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox-snarf plugin: If copying failed due to out of disk space, don't rollback the...
authorTimo Sirainen <tss@iki.fi>
Sun, 14 Dec 2008 06:36:10 +0000 (08:36 +0200)
committerTimo Sirainen <tss@iki.fi>
Sun, 14 Dec 2008 06:36:10 +0000 (08:36 +0200)
--HG--
branch : HEAD

src/plugins/mbox-snarf/mbox-snarf-plugin.c

index a851e0f6b44fa30529a9cf19aac6403f42dd93ff..1d1f370673f1b82b194b3e5ae3a8e7e62e18b11f 100644 (file)
@@ -41,6 +41,7 @@ static int mbox_snarf(struct mailbox *srcbox, struct mailbox *destbox)
        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)
@@ -61,11 +62,15 @@ static int mbox_snarf(struct mailbox *srcbox, struct mailbox *destbox)
                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);
        }