dovecot-2.1: sdbox: Fix a corrupted mailbox when opening it, ins...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 6 22:41:30 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/a765e0a895a9
changeset: 14073:a765e0a895a9
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 06 22:41:18 2012 +0200
description:
sdbox: Fix a corrupted mailbox when opening it, instead of losing all of its contents.

diffstat:

 src/lib-storage/index/dbox-single/sdbox-storage.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 833ac7b1d58b -r a765e0a895a9 src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c	Mon Feb 06 21:48:29 2012 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c	Mon Feb 06 22:41:18 2012 +0200
@@ -297,8 +297,12 @@
 					  &view, &trans, 0) > 0)
 			(void)mail_index_sync_commit(&sync_ctx);
 
-		if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
-			memset(&hdr, 0, sizeof(hdr));
+		if (sdbox_read_header(mbox, &hdr, TRUE) < 0) {
+			/* looks like the mailbox is corrupted */
+			(void)sdbox_sync(mbox, SDBOX_SYNC_FLAG_FORCE);
+			if (sdbox_read_header(mbox, &hdr, TRUE) < 0)
+				memset(&hdr, 0, sizeof(hdr));
+		}
 	}
 
 	if (guid_128_is_empty(hdr.mailbox_guid)) {


More information about the dovecot-cvs mailing list