dovecot-2.0: lib-storage: Allow mailbox_mark_index_deleted() to ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Aug 24 19:01:32 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/72b5a0af6e4e
changeset: 12040:72b5a0af6e4e
user: Timo Sirainen <tss at iki.fi>
date: Tue Aug 24 17:00:39 2010 +0100
description:
lib-storage: Allow mailbox_mark_index_deleted() to be called multiple times within same mailbox alloc.
diffstat:
src/lib-storage/mail-storage-private.h | 2 ++
src/lib-storage/mail-storage.c | 12 +++++++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diffs (41 lines):
diff -r 0f6e3c9037d5 -r 72b5a0af6e4e src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Mon Aug 23 20:15:06 2010 +0100
+++ b/src/lib-storage/mail-storage-private.h Tue Aug 24 17:00:39 2010 +0100
@@ -268,6 +268,8 @@
unsigned int backend_readonly:1;
/* Mailbox is being deleted */
unsigned int deleting:1;
+ /* Mailbox was already marked as deleted within this allocation. */
+ unsigned int marked_deleted:1;
/* TRUE if this is an INBOX for this user */
unsigned int inbox_user:1;
/* TRUE if this is an INBOX for this namespace (user or shared) */
diff -r 0f6e3c9037d5 -r 72b5a0af6e4e src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Mon Aug 23 20:15:06 2010 +0100
+++ b/src/lib-storage/mail-storage.c Tue Aug 24 17:00:39 2010 +0100
@@ -669,6 +669,12 @@
enum mail_index_transaction_flags trans_flags = 0;
struct mail_index_transaction *trans;
+ if (box->marked_deleted && del) {
+ /* we already marked it deleted. this allows plugins to
+ "lock" the deletion earlier. */
+ return 0;
+ }
+
trans_flags = del ? 0 : MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL;
trans = mail_index_transaction_begin(box->view, trans_flags);
if (del)
@@ -683,7 +689,11 @@
/* sync the mailbox. this finishes the index deletion and it can
succeed only for a single session. we do it here, so the rest of
the deletion code doesn't have to worry about race conditions. */
- return mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ);
+ if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0)
+ return -1;
+
+ box->marked_deleted = del;
+ return 0;
}
static bool mailbox_try_undelete(struct mailbox *box)
More information about the dovecot-cvs
mailing list