changeset 12944:d4945c93c33b

sdbox: If message file is unexpectedly lost, rebuild index.
author Timo Sirainen <tss@iki.fi>
date Tue, 12 Apr 2011 18:38:50 +0300
parents edf79127fccd
children bdd5a26ee180
files 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
diffstat 3 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-single/sdbox-mail.c	Tue Apr 12 18:38:00 2011 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-mail.c	Tue Apr 12 18:38:50 2011 +0300
@@ -16,10 +16,16 @@
 {
 	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)
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c	Tue Apr 12 18:38:00 2011 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c	Tue Apr 12 18:38:50 2011 +0300
@@ -196,7 +196,7 @@
 			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;
--- a/src/lib-storage/index/dbox-single/sdbox-storage.h	Tue Apr 12 18:38:00 2011 +0300
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.h	Tue Apr 12 18:38:50 2011 +0300
@@ -42,6 +42,7 @@
 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);