From: Timo Sirainen Date: Sat, 25 Oct 2008 20:56:16 +0000 (+0300) Subject: mbox: If mailbox isn't a valid mbox, don't try to sync it when closing. X-Git-Tag: 1.2.alpha4~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5afebd2df1d4990f7bec2a839260ff2e6d78168;p=thirdparty%2Fdovecot%2Fcore.git mbox: If mailbox isn't a valid mbox, don't try to sync it when closing. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/mbox/mbox-file.c b/src/lib-storage/index/mbox/mbox-file.c index d5a0c448f9..54ed986990 100644 --- a/src/lib-storage/index/mbox/mbox-file.c +++ b/src/lib-storage/index/mbox/mbox-file.c @@ -172,6 +172,7 @@ int mbox_file_seek(struct mbox_mailbox *mbox, struct mail_index_view *view, if (istream_raw_mbox_seek(mbox->mbox_stream, offset) < 0) { if (offset == 0) { + mbox->invalid_mbox_file = TRUE; mail_storage_set_error(&mbox->storage->storage, MAIL_ERROR_NOTPOSSIBLE, "Mailbox isn't a valid mbox file"); diff --git a/src/lib-storage/index/mbox/mbox-storage.c b/src/lib-storage/index/mbox/mbox-storage.c index 48d72da757..48bf5f32e4 100644 --- a/src/lib-storage/index/mbox/mbox-storage.c +++ b/src/lib-storage/index/mbox/mbox-storage.c @@ -786,7 +786,7 @@ static int mbox_storage_mailbox_close(struct mailbox *box) sync_flags |= MBOX_SYNC_REWRITE; } } - if (sync_flags != 0) { + if (sync_flags != 0 && !mbox->invalid_mbox_file) { if (mbox_sync(mbox, sync_flags) < 0) ret = -1; } diff --git a/src/lib-storage/index/mbox/mbox-storage.h b/src/lib-storage/index/mbox/mbox-storage.h index c154de0a63..cd0ae80eab 100644 --- a/src/lib-storage/index/mbox/mbox-storage.h +++ b/src/lib-storage/index/mbox/mbox-storage.h @@ -42,6 +42,7 @@ struct mbox_mailbox { uint32_t mbox_ext_idx; unsigned int no_mbox_file:1; + unsigned int invalid_mbox_file:1; unsigned int mbox_sync_dirty:1; unsigned int mbox_do_dirty_syncs:1; unsigned int mbox_very_dirty_syncs:1; diff --git a/src/lib-storage/index/mbox/mbox-sync.c b/src/lib-storage/index/mbox/mbox-sync.c index f4711f2d1e..55feed8535 100644 --- a/src/lib-storage/index/mbox/mbox-sync.c +++ b/src/lib-storage/index/mbox/mbox-sync.c @@ -808,6 +808,7 @@ mbox_sync_seek_to_seq(struct mbox_sync_context *sync_ctx, uint32_t seq) if (seq == 0) { if (istream_raw_mbox_seek(mbox->mbox_stream, 0) < 0) { + mbox->invalid_mbox_file = TRUE; mail_storage_set_error(&mbox->storage->storage, MAIL_ERROR_NOTPOSSIBLE, "Mailbox isn't a valid mbox file");