dovecot-2.1: imapc: Fixed fetching data for a saved, but uncommi...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 5 17:47:10 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/09707b608d8d
changeset: 13609:09707b608d8d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 05 17:55:29 2011 +0300
description:
imapc: Fixed fetching data for a saved, but uncommitted, mail.

diffstat:

 src/lib-storage/index/imapc/imapc-mail-fetch.c |  29 ++++++++++++++-----------
 src/lib-storage/index/imapc/imapc-storage.c    |   9 ++++---
 src/lib-storage/index/imapc/imapc-storage.h    |   1 +
 3 files changed, 22 insertions(+), 17 deletions(-)

diffs (73 lines):

diff -r fab95106bcd6 -r 09707b608d8d src/lib-storage/index/imapc/imapc-mail-fetch.c
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c	Wed Oct 05 17:51:32 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c	Wed Oct 05 17:55:29 2011 +0300
@@ -68,20 +68,23 @@
 	if (fields == 0)
 		return 0;
 
-	if (_mail->saving) {
-		mail_storage_set_critical(_mail->box->storage,
-			"Can't fetch data from uncommitted message");
-		return -1;
-	}
+	if (!_mail->saving) {
+		/* if we already know that the mail is expunged,
+		   don't try to FETCH it */
+		view = mbox->delayed_sync_view != NULL ?
+			mbox->delayed_sync_view : mbox->box.view;
+		if (!mail_index_lookup_seq(view, _mail->uid, &seq) ||
+		    mail_index_is_expunged(view, seq)) {
+			mail_set_expunged(_mail);
+			return -1;
+		}
+	} else if (mbox->client_box == NULL) {
+		/* opened as save-only. we'll need to fetch the mail,
+		   so actually SELECT/EXAMINE the mailbox */
+		i_assert(mbox->box.opened);
 
-	/* if we already know that the mail is expunged,
-	   don't try to FETCH it */
-	view = mbox->delayed_sync_view != NULL ?
-		mbox->delayed_sync_view : mbox->box.view;
-	if (!mail_index_lookup_seq(view, _mail->uid, &seq) ||
-	    mail_index_is_expunged(view, seq)) {
-		mail_set_expunged(_mail);
-		return -1;
+		if (imapc_mailbox_select(mbox) < 0)
+			return -1;
 	}
 
 	if ((fields & MAIL_FETCH_STREAM_BODY) != 0)
diff -r fab95106bcd6 -r 09707b608d8d src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c	Wed Oct 05 17:51:32 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Wed Oct 05 17:55:29 2011 +0300
@@ -383,13 +383,14 @@
 	imapc_client_stop(ctx->mbox->storage->client);
 }
 
-static int imapc_mailbox_select(struct imapc_mailbox *mbox)
+int imapc_mailbox_select(struct imapc_mailbox *mbox)
 {
 	struct imapc_open_context ctx;
-	bool examine;
+	bool examine = TRUE;
 
-	examine = (mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 &&
-		(mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0;
+	examine = (mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0 &&
+		((mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 ||
+		 (mbox->box.flags & MAILBOX_FLAG_SAVEONLY) != 0);
 
 	mbox->selecting = TRUE;
 	ctx.mbox = mbox;
diff -r fab95106bcd6 -r 09707b608d8d src/lib-storage/index/imapc/imapc-storage.h
--- a/src/lib-storage/index/imapc/imapc-storage.h	Wed Oct 05 17:51:32 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.h	Wed Oct 05 17:55:29 2011 +0300
@@ -105,6 +105,7 @@
 
 void imapc_storage_run(struct imapc_storage *storage);
 void imapc_mail_cache_free(struct imapc_mail_cache *cache);
+int imapc_mailbox_select(struct imapc_mailbox *mbox);
 
 void imapc_copy_error_from_reply(struct imapc_storage *storage,
 				 enum mail_error default_error,


More information about the dovecot-cvs mailing list