]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fixed fetching data for a saved, but uncommitted, mail.
authorTimo Sirainen <tss@iki.fi>
Wed, 5 Oct 2011 14:55:29 +0000 (17:55 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 5 Oct 2011 14:55:29 +0000 (17:55 +0300)
src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/imapc/imapc-storage.h

index 0ec352db4de74cbfe789397fd115d527aaabe9fa..a8ffea859b426d936ed388a0022f65f55afe94cd 100644 (file)
@@ -68,20 +68,23 @@ imapc_mail_send_fetch(struct mail *_mail, enum mail_fetch_field fields)
        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)
index e0122290c76a8bc3853a179cc68bb650d2688f97..54b807f593ce7aa6d151a26f8ccc99d4fd7c1afb 100644 (file)
@@ -383,13 +383,14 @@ imapc_mailbox_open_callback(const struct imapc_command_reply *reply,
        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;
index d5563eb3e9080299e988602feea8281ba50e560a..ce079ad91e684cde6540de017d9d3efe5cb82cfd 100644 (file)
@@ -105,6 +105,7 @@ void imapc_transaction_save_rollback(struct mail_save_context *ctx);
 
 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,