]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_index_unset_fscked()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Nov 2016 15:16:30 +0000 (17:16 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 25 Nov 2016 13:30:49 +0000 (15:30 +0200)
This can be used to easily remove MAIL_INDEX_HDR_FLAG_FSCKD. It takes a
transaction parameter instead of sync_ctx because some index rebuilds
are done with a separate transaction while the sync_ctx is rolled back.

src/lib-index/mail-index-transaction-update.c
src/lib-index/mail-index.h

index 5a39d1e6a3ad23e2c7c6cb10a3ebaf5681cbd9b4..c5012acfd2c51707301517061372b823d6fa61e7 100644 (file)
@@ -1307,6 +1307,22 @@ void mail_index_reset(struct mail_index_transaction *t)
        t->reset = TRUE;
 }
 
+void mail_index_unset_fscked(struct mail_index_transaction *t)
+{
+       struct mail_index_header new_hdr =
+               *mail_index_get_header(t->view);
+
+       i_assert(t->view->index->log_sync_locked);
+
+       /* remove fsck'd-flag if it exists. */
+       if ((new_hdr.flags & MAIL_INDEX_HDR_FLAG_FSCKD) != 0) {
+               new_hdr.flags &= ~MAIL_INDEX_HDR_FLAG_FSCKD;
+               mail_index_update_header(t,
+                       offsetof(struct mail_index_header, flags),
+                       &new_hdr.flags, sizeof(new_hdr.flags), FALSE);
+       }
+}
+
 void mail_index_set_deleted(struct mail_index_transaction *t)
 {
        i_assert(!t->index_undeleted);
index 82b38c9d6b57d075df96a9904046385eccf4118f..c493c72d13be3f33d26fe0ae888a3aecd208d9d4 100644 (file)
@@ -523,6 +523,9 @@ void mail_index_update_highest_modseq(struct mail_index_transaction *t,
 /* Reset the index before committing this transaction. This is usually done
    only when UIDVALIDITY changes. */
 void mail_index_reset(struct mail_index_transaction *t);
+/* Remove MAIL_INDEX_HDR_FLAG_FSCKD from header if it exists. This must be
+   called only during syncing so that the mailbox is locked. */
+void mail_index_unset_fscked(struct mail_index_transaction *t);
 /* Mark index deleted. No further changes will be possible after the
    transaction has been committed. */
 void mail_index_set_deleted(struct mail_index_transaction *t);