]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add MAILBOX_FLAG_FSCK to fsck index immediately after opening it
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 May 2018 18:31:59 +0000 (21:31 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 21 Nov 2018 10:59:12 +0000 (12:59 +0200)
This can be used to fix a broken index that is causing mailbox_open() to
fail.

src/lib-storage/index/index-storage.c
src/lib-storage/mail-storage.h

index 218b6241410f9b0b41c3ba569b79e7f2d2946d09..56199fdb4f98ae415bb5c455b0d999205f83bc55 100644 (file)
@@ -332,6 +332,12 @@ int index_storage_mailbox_open(struct mailbox *box, bool move_to_memory)
                        return -1;
                }
        }
+       if ((box->flags & MAILBOX_FLAG_FSCK) != 0) {
+               if (mail_index_fsck(box->index) < 0) {
+                       mailbox_set_index_error(box);
+                       return -1;
+               }
+       }
 
        box->cache = mail_index_get_cache(box->index);
        index_cache_register_defaults(box);
index f863993717a062826f0f00b1d0da1ecf346f3c3b..5b7b6fc7fc979519a33159f15b515e0277a60145 100644 (file)
@@ -68,7 +68,11 @@ enum mailbox_flags {
        /* Mailbox is created implicitly if it does not exist. */
        MAILBOX_FLAG_AUTO_CREATE        = 0x1000,
        /* Mailbox is subscribed to implicitly when it is created automatically */
-       MAILBOX_FLAG_AUTO_SUBSCRIBE     = 0x2000
+       MAILBOX_FLAG_AUTO_SUBSCRIBE     = 0x2000,
+       /* Run fsck for mailbox index before doing anything else. This may be
+          useful in fixing index corruption errors that aren't otherwise
+          detected and that are causing the full mailbox opening to fail. */
+       MAILBOX_FLAG_FSCK               = 0x4000,
 };
 
 enum mailbox_feature {