dovecot-2.2: dsync: If mailbox UIDVALIDITY is 0, sync it to assi...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jan 31 18:47:32 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/86629f621fe4
changeset: 15697:86629f621fe4
user: Timo Sirainen <tss at iki.fi>
date: Thu Jan 31 18:47:20 2013 +0200
description:
dsync: If mailbox UIDVALIDITY is 0, sync it to assign it instead of assert-crashing.
diffstat:
src/doveadm/dsync/dsync-mailbox-tree-fill.c | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diffs (52 lines):
diff -r 2801de211b78 -r 86629f621fe4 src/doveadm/dsync/dsync-mailbox-tree-fill.c
--- a/src/doveadm/dsync/dsync-mailbox-tree-fill.c Thu Jan 31 18:39:44 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-tree-fill.c Thu Jan 31 18:47:20 2013 +0200
@@ -30,6 +30,30 @@
return 0;
}
+static int
+dsync_mailbox_tree_get_selectable(struct mailbox *box,
+ struct mailbox_metadata *metadata_r,
+ struct mailbox_status *status_r)
+{
+ /* try the fast path */
+ if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, metadata_r) < 0)
+ return -1;
+ if (mailbox_get_status(box, STATUS_UIDVALIDITY, status_r) < 0)
+ return -1;
+
+ i_assert(!guid_128_is_empty(metadata_r->guid));
+ if (status_r->uidvalidity != 0)
+ return 0;
+
+ /* no UIDVALIDITY assigned yet. syncing a mailbox should add it. */
+ if (mailbox_sync(box, 0) < 0)
+ return -1;
+ if (mailbox_get_status(box, STATUS_UIDVALIDITY, status_r) < 0)
+ return -1;
+ i_assert(status_r->uidvalidity != 0);
+ return 0;
+}
+
static int dsync_mailbox_tree_add(struct dsync_mailbox_tree *tree,
const struct mailbox_info *info)
{
@@ -52,8 +76,7 @@
/* get GUID and UIDVALIDITY for selectable mailbox */
box = mailbox_alloc(info->ns->list, info->vname, 0);
- if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0 ||
- mailbox_get_status(box, STATUS_UIDVALIDITY, &status) < 0) {
+ if (dsync_mailbox_tree_get_selectable(box, &metadata, &status) < 0) {
errstr = mailbox_get_last_error(box, &error);
switch (error) {
case MAIL_ERROR_NOTFOUND:
@@ -69,7 +92,6 @@
return -1;
}
} else {
- i_assert(status.uidvalidity != 0);
memcpy(node->mailbox_guid, metadata.guid,
sizeof(node->mailbox_guid));
node->uid_validity = status.uidvalidity;
More information about the dovecot-cvs
mailing list