dovecot: Moved mailbox_deleted to struct mailbox. Added and used

dovecot at dovecot.org dovecot at dovecot.org
Sun Nov 11 16:02:29 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/fd9effba151d
changeset: 6771:fd9effba151d
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Nov 11 16:02:25 2007 +0200
description:
Moved mailbox_deleted to struct mailbox. Added and used
mailbox_set_deleted() which also sets an error message to storage.

diffstat:

6 files changed, 16 insertions(+), 8 deletions(-)
src/lib-storage/index/dbox/dbox-sync-rebuild.c |    2 +-
src/lib-storage/index/index-storage.c          |    3 +--
src/lib-storage/index/index-storage.h          |    1 -
src/lib-storage/index/maildir/maildir-sync.c   |    4 ++--
src/lib-storage/mail-storage-private.h         |    3 +++
src/lib-storage/mail-storage.c                 |   11 +++++++++--

diffs (95 lines):

diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/index/dbox/dbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Sun Nov 11 16:02:25 2007 +0200
@@ -272,7 +272,7 @@ static int dbox_sync_index_rebuild_dir(s
 	dir = opendir(path);
 	if (dir == NULL) {
 		if (errno == ENOENT) {
-			ctx->mbox->ibox.mailbox_deleted = TRUE;
+			mailbox_set_deleted(&ctx->mbox->ibox.box);
 			return -1;
 		}
 		mail_storage_set_critical(storage,
diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/index/index-storage.c	Sun Nov 11 16:02:25 2007 +0200
@@ -465,8 +465,7 @@ bool index_storage_is_inconsistent(struc
 {
 	struct index_mailbox *ibox = (struct index_mailbox *) box;
 
-	return mail_index_view_is_inconsistent(ibox->view) ||
-		ibox->mailbox_deleted;
+	return mail_index_view_is_inconsistent(ibox->view);
 }
 
 void mail_storage_set_index_error(struct index_mailbox *ibox)
diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/index/index-storage.h	Sun Nov 11 16:02:25 2007 +0200
@@ -64,7 +64,6 @@ struct index_mailbox {
 	unsigned int notify_pending:1;
 	unsigned int move_to_memory:1;
 	unsigned int fsync_disable:1;
-	unsigned int mailbox_deleted:1;
 };
 
 struct index_transaction_context {
diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Sun Nov 11 16:02:25 2007 +0200
@@ -342,7 +342,7 @@ maildir_stat(struct maildir_mailbox *mbo
 		return 0;
 	if (errno == ENOENT) {
 		/* if mailbox gets deleted under us, don't log an error */
-		mbox->ibox.mailbox_deleted = TRUE;
+		mailbox_set_deleted(&mbox->ibox.box);
 		return -1;
 	}
 
@@ -369,7 +369,7 @@ static int maildir_scan_dir(struct maild
 	dirp = opendir(path);
 	if (dirp == NULL) {
 		if (errno == ENOENT) {
-			ctx->mbox->ibox.mailbox_deleted = TRUE;
+			mailbox_set_deleted(&ctx->mbox->ibox.box);
 			return -1;
 		}
 		mail_storage_set_critical(storage,
diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/mail-storage-private.h	Sun Nov 11 16:02:25 2007 +0200
@@ -196,6 +196,8 @@ struct mailbox {
 	/* When FAST open flag is used, the mailbox isn't actually opened until
 	   it's synced for the first time. */
 	unsigned int opened:1;
+	/* Mailbox was deleted while we had it open. */
+	unsigned int mailbox_deleted:1;
 };
 
 struct mail_vfuncs {
@@ -316,6 +318,7 @@ bool mail_storage_set_error_from_errno(s
 bool mail_storage_set_error_from_errno(struct mail_storage *storage);
 
 void mail_set_expunged(struct mail *mail);
+void mailbox_set_deleted(struct mailbox *box);
 
 enum mailbox_list_flags
 mail_storage_get_list_flags(enum mail_storage_flags storage_flags);
diff -r 083681d2f4fb -r fd9effba151d src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Sun Nov 11 15:48:59 2007 +0200
+++ b/src/lib-storage/mail-storage.c	Sun Nov 11 16:02:25 2007 +0200
@@ -741,5 +741,12 @@ int mailbox_copy(struct mailbox_transact
 
 bool mailbox_is_inconsistent(struct mailbox *box)
 {
-	return box->v.is_inconsistent(box);
-}
+	return box->mailbox_deleted || box->v.is_inconsistent(box);
+}
+
+void mailbox_set_deleted(struct mailbox *box)
+{
+	mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
+			       "Mailbox was deleted under us");
+	box->mailbox_deleted = TRUE;
+}


More information about the dovecot-cvs mailing list