]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: When index is reset, make sure old dovecot.index gets deleted.
authorTimo Sirainen <tss@iki.fi>
Mon, 8 Mar 2010 17:53:28 +0000 (19:53 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 8 Mar 2010 17:53:28 +0000 (19:53 +0200)
--HG--
branch : HEAD

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

index 38f2d58383ce6760728e65e51e3d111f55eb47f7..95b0760b5fb34d1f74ac25fa42a3c7494ec75ae3 100644 (file)
@@ -146,6 +146,13 @@ mail_index_transaction_commit_real(struct mail_index_transaction *t,
        mail_transaction_log_get_head(log, &log_seq2, &log_offset2);
        i_assert(log_seq1 == log_seq2);
 
+       if (t->reset) {
+               /* get rid of the old index. it might just confuse readers,
+                  especially if it's broken. */
+               if (unlink(log->index->filepath) < 0 && errno != ENOENT)
+                       i_error("unlink(%s) failed: %m", log->index->filepath);
+       }
+
        *commit_size_r = log_offset2 - log_offset1;
 
        if ((t->flags & MAIL_INDEX_TRANSACTION_FLAG_HIDE) != 0 &&