Mercurial > dovecot > core-2.2
changeset 22058:57e28dbf5bc1
lib-storage: Fix mailbox list index records without guid having invalid flags
With LAYOUT=index the mailbox is found with its GUID. If it doesn't exist,
the mailbox has to be either \NonExistent or \NoSelect. It probably doesn't
make much difference which one, so we'll fix them by adding \NoSelect.
With other layouts the GUID is allowed to be empty, because it can be looked
up from the actual mailbox.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 18 May 2017 23:13:38 +0300 |
parents | 5ea34f725a3a |
children | b6ec79a3d312 |
files | src/lib-storage/list/mailbox-list-index-sync.c src/lib-storage/list/mailbox-list-index.c src/lib-storage/list/mailbox-list-index.h |
diffstat | 3 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index-sync.c Thu May 18 23:06:20 2017 +0300 +++ b/src/lib-storage/list/mailbox-list-index-sync.c Thu May 18 23:13:38 2017 +0300 @@ -388,7 +388,11 @@ sync_ctx->ilist->ext_id, &irec, NULL); node->corrupted_ext = FALSE; } - if ((node->flags & MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME) != 0) { + if (node->corrupted_flags) { + mail_index_update_flags(sync_ctx->trans, seq, MODIFY_REPLACE, + (enum mail_flags)node->flags); + node->corrupted_flags = FALSE; + } else if ((node->flags & MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME) != 0) { /* rely on lib-index to drop unnecessary updates */ mail_index_update_flags(sync_ctx->trans, seq, MODIFY_ADD, (enum mail_flags)MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME);
--- a/src/lib-storage/list/mailbox-list-index.c Thu May 18 23:06:20 2017 +0300 +++ b/src/lib-storage/list/mailbox-list-index.c Thu May 18 23:13:38 2017 +0300 @@ -318,6 +318,17 @@ } irec = data; + if (!ilist->has_backing_store && guid_128_is_empty(irec->guid) && + (rec->flags & (MAILBOX_LIST_INDEX_FLAG_NONEXISTENT | + MAILBOX_LIST_INDEX_FLAG_NOSELECT)) == 0) { + /* no backing store and mailbox has no GUID. + it can't be selectable, but the flag is missing. */ + node->flags |= MAILBOX_LIST_INDEX_FLAG_NOSELECT; + *error_r = "mailbox is missing guid - " + "setting it non-selectable"; + node->corrupted_flags = TRUE; + } + node->name_id = irec->name_id; if (node->name_id == 0) { /* invalid name_id - assign a new one */
--- a/src/lib-storage/list/mailbox-list-index.h Thu May 18 23:06:20 2017 +0300 +++ b/src/lib-storage/list/mailbox-list-index.h Thu May 18 23:13:38 2017 +0300 @@ -83,6 +83,8 @@ enum mailbox_list_index_flags flags; /* extension data is corrupted on disk - need to update it */ bool corrupted_ext; + /* flags are corrupted on disk - need to update it */ + bool corrupted_flags; const char *name; };