Skip to content

Commit

Permalink
lib-storage: Add MAILBOX_FLAG_FSCK to fsck index immediately after op…
Browse files Browse the repository at this point in the history
…ening it

This can be used to fix a broken index that is causing mailbox_open() to
fail.
  • Loading branch information
sirainen authored and villesavolainen committed Nov 21, 2018
1 parent 71fa7e3 commit 689c517
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/lib-storage/index/index-storage.c
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/lib-storage/mail-storage.h
Expand Up @@ -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 {
Expand Down

0 comments on commit 689c517

Please sign in to comment.