]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
sdbox: If message file is unexpectedly lost, rebuild index.
authorTimo Sirainen <tss@iki.fi>
Tue, 12 Apr 2011 15:38:50 +0000 (18:38 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 12 Apr 2011 15:38:50 +0000 (18:38 +0300)
src/lib-storage/index/dbox-single/sdbox-mail.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.h

index 2efdf25002207dd2c6af6fe50843cba8f7c17699..76586a714193be4b4ad9aba32816c4f9498b9828 100644 (file)
@@ -16,10 +16,16 @@ static void sdbox_mail_set_expunged(struct dbox_mail *mail)
 {
        struct mail *_mail = &mail->imail.mail.mail;
 
-       /* syncing code first unlinks the file, and index is updated later.
-          so at this point we don't know if the file was unexpectedly lost
-          or if it's just being expunged. just assume the latter. */
-       mail_set_expunged(_mail);
+       (void)mail_index_refresh(_mail->box->index);
+       if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) {
+               mail_set_expunged(_mail);
+               return;
+       }
+
+       mail_storage_set_critical(_mail->box->storage,
+                                 "dbox %s: Unexpectedly lost uid=%u",
+                                 _mail->box->path, _mail->uid);
+       sdbox_set_mailbox_corrupted(_mail->box);
 }
 
 static bool sdbox_mail_file_set(struct dbox_mail *mail)
index 576fd7fd1cd6ccf65cf6576f56a5d9e85460e21f..5c0bc20b628a5418630eda585aeae90e6a5d0b1f 100644 (file)
@@ -196,7 +196,7 @@ sdbox_get_attachment_path_suffix(struct dbox_file *_file)
                        file->uid);
 }
 
-static void sdbox_set_mailbox_corrupted(struct mailbox *box)
+void sdbox_set_mailbox_corrupted(struct mailbox *box)
 {
        struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)box;
        struct sdbox_index_header hdr;
index e7ebba3804df10446955cd089938b48109d826d9..8bc00163343e7e6e527739487dbd8c90c3f4fffa 100644 (file)
@@ -42,6 +42,7 @@ int sdbox_read_header(struct sdbox_mailbox *mbox,
 void sdbox_update_header(struct sdbox_mailbox *mbox,
                         struct mail_index_transaction *trans,
                         const struct mailbox_update *update);
+void sdbox_set_mailbox_corrupted(struct mailbox *box);
 
 struct mail_save_context *
 sdbox_save_alloc(struct mailbox_transaction_context *_t);