changeset 10733:1afcc09c2c6c HEAD

mbox: Make sure we have valid mailbox GUID when returning it.
author Timo Sirainen <tss@iki.fi>
date Mon, 15 Feb 2010 07:08:40 +0200
parents 8f251e0bc02d
children 8d5e2deb4ce0
files src/lib-storage/index/mbox/mbox-storage.c src/lib-storage/mail-storage.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-storage.c	Mon Feb 15 06:12:59 2010 +0200
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Mon Feb 15 07:08:40 2010 +0200
@@ -573,6 +573,10 @@
 			"Mailbox GUIDs are not permanent without index files");
 		return -1;
 	}
+	if (mail_guid_128_is_empty(mbox->mbox_hdr.mailbox_guid)) {
+		if (mailbox_sync(&mbox->box, 0) < 0)
+			return -1;
+	}
 	memcpy(guid, mbox->mbox_hdr.mailbox_guid, MAIL_GUID_128_SIZE);
 	return 0;
 }
--- a/src/lib-storage/mail-storage.c	Mon Feb 15 06:12:59 2010 +0200
+++ b/src/lib-storage/mail-storage.c	Mon Feb 15 07:08:40 2010 +0200
@@ -824,7 +824,11 @@
 		if (mailbox_open(box) < 0)
 			return -1;
 	}
-	return box->v.get_guid(box, guid);
+	if (box->v.get_guid(box, guid) < 0)
+		return -1;
+
+	i_assert(!mail_guid_128_is_empty(guid));
+	return 0;
 }
 
 struct mailbox_sync_context *