]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add rebuild reason for mail_storage.list_index_corrupted()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 29 Nov 2017 13:39:45 +0000 (15:39 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 29 Nov 2017 13:39:45 +0000 (15:39 +0200)
This is done in a bit kludgy way to keep API backwards compatible.
v2.3 cleans this up.

src/lib-storage/list/mailbox-list-index.c
src/lib-storage/mail-storage-private.h

index 4fe2203d477afe2777c34901df8e7a4131cb6eeb..c1fbb31e694921e6797e110f2294fd86c6d85654 100644 (file)
@@ -587,9 +587,12 @@ int mailbox_list_index_handle_corruption(struct mailbox_list *list)
 {
        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 @@ int mailbox_list_index_handle_corruption(struct mailbox_list *list)
 
        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 {
index f230041ecf361d6d281cc6abc9bec64d6f61fd59..63742cdf38118bce8c22738e539df60289a55e52 100644 (file)
 
 #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 @@ struct mail_storage_vfuncs {
                                         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 {
        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. */