changeset 15670:1706b3490966

imapc: Avoid unnecessarily selecting a mailbox when looking up its GUID.
author Timo Sirainen <tss@iki.fi>
date Tue, 22 Jan 2013 12:49:04 +0200
parents be5ce6c06b08
children aa60f457a23f
files src/lib-storage/index/imapc/imapc-storage.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-storage.c	Mon Jan 21 19:45:13 2013 +0200
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Tue Jan 22 12:49:04 2013 +0200
@@ -755,12 +755,11 @@
 	struct imapc_mailbox *mbox = (struct imapc_mailbox *)box;
 	const struct imapc_namespace *ns;
 
-	if (index_mailbox_get_metadata(box, items, metadata_r) < 0)
-		return -1;
 	if ((items & MAILBOX_METADATA_GUID) != 0) {
 		/* a bit ugly way to do this, but better than nothing for now.
 		   FIXME: if indexes are enabled, keep this there. */
 		mail_generate_guid_128_hash(box->name, metadata_r->guid);
+		items &= ~MAILBOX_METADATA_GUID;
 	}
 	if ((items & MAILBOX_METADATA_BACKEND_NAMESPACE) != 0) {
 		if (imapc_mailbox_get_namespaces(mbox->storage) < 0)
@@ -771,6 +770,11 @@
 			metadata_r->backend_ns_prefix = ns->prefix;
 			metadata_r->backend_ns_type = ns->type;
 		}
+		items &= ~MAILBOX_METADATA_BACKEND_NAMESPACE;
+	}
+	if (items != 0) {
+		if (index_mailbox_get_metadata(box, items, metadata_r) < 0)
+			return -1;
 	}
 	return 0;
 }