dovecot-2.2: lib-storage: Make sure mailbox was synced at least ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 13:01:51 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/41018c6fcc53
changeset: 15265:41018c6fcc53
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 13:01:37 2012 +0200
description:
lib-storage: Make sure mailbox was synced at least once when getting status/metadata.

diffstat:

 src/lib-storage/index/index-status.c |  6 ++++++
 src/lib-storage/mail-storage.h       |  3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diffs (36 lines):

diff -r 3d7edc15fcec -r 41018c6fcc53 src/lib-storage/index/index-status.c
--- a/src/lib-storage/index/index-status.c	Mon Oct 29 13:00:36 2012 +0200
+++ b/src/lib-storage/index/index-status.c	Mon Oct 29 13:01:37 2012 +0200
@@ -36,6 +36,8 @@
 	if (!box->opened) {
 		if (mailbox_open(box) < 0)
 			return -1;
+	}
+	if (!box->synced) {
 		if (mailbox_sync(box, 0) < 0)
 			return -1;
 	}
@@ -357,6 +359,10 @@
 		if (mailbox_open(box) < 0)
 			return -1;
 	}
+	if (!box->synced && (items & MAILBOX_METADATA_SYNC_ITEMS) != 0) {
+		if (mailbox_sync(box, 0) < 0)
+			return -1;
+	}
 
 	if ((items & MAILBOX_METADATA_VIRTUAL_SIZE) != 0) {
 		if (get_metadata_virtual_size(box, metadata_r) < 0)
diff -r 3d7edc15fcec -r 41018c6fcc53 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h	Mon Oct 29 13:00:36 2012 +0200
+++ b/src/lib-storage/mail-storage.h	Mon Oct 29 13:01:37 2012 +0200
@@ -85,6 +85,9 @@
 	MAILBOX_METADATA_CACHE_FIELDS		= 0x04,
 	MAILBOX_METADATA_PRECACHE_FIELDS	= 0x08,
 	MAILBOX_METADATA_BACKEND_NAMESPACE	= 0x10
+	/* metadata items that require mailbox to be synced at least once. */
+#define MAILBOX_METADATA_SYNC_ITEMS \
+	(MAILBOX_METADATA_GUID | MAILBOX_METADATA_VIRTUAL_SIZE)
 };
 
 enum mailbox_search_result_flags {


More information about the dovecot-cvs mailing list