Mercurial > dovecot > core-2.2
changeset 22696:090bb542ae58
lib-storage: Add rebuild reason for mail_storage.list_index_corrupted()
This is done in a bit kludgy way to keep API backwards compatible.
v2.3 cleans this up.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 29 Nov 2017 15:39:45 +0200 |
parents | 338c32a16562 |
children | bc0c97a0c7d6 |
files | src/lib-storage/list/mailbox-list-index.c src/lib-storage/mail-storage-private.h |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-index.c Wed Nov 29 14:38:38 2017 +0200 +++ b/src/lib-storage/list/mailbox-list-index.c Wed Nov 29 15:39:45 2017 +0200 @@ -587,9 +587,12 @@ { struct mailbox_list_index *ilist = INDEX_LIST_CONTEXT(list); struct mail_storage *const *storagep; + enum mail_storage_list_index_rebuild_reason reason; int ret = 0; - if (!ilist->call_corruption_callback) + if (ilist->call_corruption_callback) + reason = MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_CORRUPTED; + else return 0; /* make sure we don't recurse */ @@ -599,6 +602,7 @@ array_foreach(&list->ns->all_storages, storagep) { if ((*storagep)->v.list_index_corrupted != NULL) { + (*storagep)->list_index_rebuild_reason = reason; if ((*storagep)->v.list_index_corrupted(*storagep) < 0) ret = -1; else {
--- a/src/lib-storage/mail-storage-private.h Wed Nov 29 14:38:38 2017 +0200 +++ b/src/lib-storage/mail-storage-private.h Wed Nov 29 15:39:45 2017 +0200 @@ -20,6 +20,11 @@ #define MAIL_SHARED_STORAGE_NAME "shared" +enum mail_storage_list_index_rebuild_reason { + /* Mailbox list index was found to be corrupted. */ + MAIL_STORAGE_LIST_INDEX_REBUILD_REASON_CORRUPTED, +}; + struct mail_storage_module_register { unsigned int id; }; @@ -48,10 +53,12 @@ const char *vname, enum mailbox_flags flags); int (*purge)(struct mail_storage *storage); - /* Called when mailbox list index corruption has been detected. + /* Called when mailbox list index rebuild is requested. Additional + parameter is in storage.list_index_rebuild_reason. + The callback should add any missing mailboxes to the list index. Returns 0 on success, -1 on temporary failure that didn't properly - fix the index. */ + rebuild the index. */ int (*list_index_corrupted)(struct mail_storage *storage); }; @@ -152,6 +159,10 @@ struct mail_storage_callbacks callbacks; void *callback_context; + /* FIXME: remove in v2.3 - should be a parameter to + list_index_corrupted() */ + enum mail_storage_list_index_rebuild_reason list_index_rebuild_reason; + struct mail_binary_cache binary_cache; /* Filled lazily by mailbox_attribute_*() when accessing shared attributes. */