Mercurial > dovecot > core-2.2
changeset 22697:bc0c97a0c7d6
LAYOUT=index: Rebuild list index if INBOX is missing on inbox=yes namespace
This avoids having to manually rebuild the list index afterwards if it
becomes lost.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 29 Nov 2017 14:51:02 +0200 |
parents | 090bb542ae58 |
children | bdb8b4e03f1b |
files | src/lib-storage/list/mailbox-list-index.c src/lib-storage/list/mailbox-list-index.h src/lib-storage/mail-storage-private.h |
diffstat | 3 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index.c Wed Nov 29 15:39:45 2017 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Wed Nov 29 14:51:02 2017 +0200 @@ -398,6 +398,8 @@ parent->children = node; continue; } + } else if (strcasecmp(node->name, "INBOX") == 0) { + ilist->rebuild_on_missing_inbox = FALSE; } if (hash_table_lookup(duplicate_hash, node) == NULL) hash_table_insert(duplicate_hash, node, node); @@ -592,6 +594,8 @@ if (ilist->call_corruption_callback) reason = MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_CORRUPTED; + else if (ilist->rebuild_on_missing_inbox) + reason = MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_NO_INBOX; else return 0; @@ -624,6 +628,7 @@ struct mailbox_list_index_sync_context *sync_ctx; ilist->call_corruption_callback = FALSE; + ilist->rebuild_on_missing_inbox = FALSE; if (mailbox_list_index_sync_begin(list, &sync_ctx) < 0) return -1; @@ -904,6 +909,8 @@ ilist->path = dir == NULL ? "(in-memory mailbox list index)" : p_strdup_printf(list->pool, "%s/%s", dir, list->set.list_index_fname); ilist->index = mail_index_alloc(dir, list->set.list_index_fname); + ilist->rebuild_on_missing_inbox = + (list->ns->flags & NAMESPACE_FLAG_INBOX_ANY) != 0; ilist->ext_id = mail_index_ext_register(ilist->index, "list", sizeof(struct mailbox_list_index_header),
--- a/src/lib-storage/list/mailbox-list-index.h Wed Nov 29 15:39:45 2017 +0200 +++ b/src/lib-storage/list/mailbox-list-index.h Wed Nov 29 14:51:02 2017 +0200 @@ -121,6 +121,7 @@ unsigned int corrupted_names_or_parents:1; unsigned int handling_corruption:1; unsigned int call_corruption_callback:1; + unsigned int rebuild_on_missing_inbox:1; }; struct mailbox_list_index_iterate_context {
--- a/src/lib-storage/mail-storage-private.h Wed Nov 29 15:39:45 2017 +0200 +++ b/src/lib-storage/mail-storage-private.h Wed Nov 29 14:51:02 2017 +0200 @@ -23,6 +23,12 @@ enum mail_storage_list_index_rebuild_reason { /* Mailbox list index was found to be corrupted. */ MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_CORRUPTED, + /* Mailbox list index doesn't have INBOX in an inbox=yes namespace. + Rebuild is done to verify whether the user really is an empty new + user, or if an existing user's mailbox list index was lost. Because + this is called in non-error conditions, the callback shouldn't log + any errors or warnings if it didn't find any missing mailboxes. */ + MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_NO_INBOX, }; struct mail_storage_module_register {