diff --git a/resources/mixedmaildir/mixedmaildirstore.cpp b/resources/mixedmaildir/mixedmaildirstore.cpp --- a/resources/mixedmaildir/mixedmaildirstore.cpp +++ b/resources/mixedmaildir/mixedmaildirstore.cpp @@ -1659,10 +1659,10 @@ const bool includeHeaders = scope.payloadParts().contains(MessagePart::Header) || scope.payloadParts().contains(MessagePart::Envelope); - const bool fetchSingleItem = job->collection().remoteId().isEmpty(); - const bool fetchItemsBatch = !job->items().isEmpty() && !job->item().isValid(); - const Collection collection = fetchSingleItem ? job->item().parentCollection() : - fetchItemsBatch ? job->items().at(0).parentCollection() : + const bool fetchItemsBatch = !job->requestedItems().isEmpty(); + const bool fetchSingleItem = job->collection().remoteId().isEmpty() && !fetchItemsBatch; + const Collection collection = fetchItemsBatch ? job->requestedItems().at(0).parentCollection() : + fetchSingleItem ? job->item().parentCollection() : job->collection(); QString path; @@ -1699,7 +1699,7 @@ if (fetchSingleItem) { items << job->item(); } else if (fetchItemsBatch) { - items = job->items(); + items = job->requestedItems(); } else { listCollection(job, findIt.value(), collection, items); } @@ -1740,7 +1740,7 @@ if (fetchSingleItem) { items << job->item(); } else if (fetchItemsBatch) { - items = job->items(); + items = job->requestedItems(); } else { listCollection(job, mdPtr, collection, items); } @@ -2388,10 +2388,16 @@ { Q_UNUSED(errorCode); Q_UNUSED(errorText); - const bool fetchSingleItem = job->collection().remoteId().isEmpty(); - if (fetchSingleItem) { - Collection coll = job->item().parentCollection(); - Q_ASSERT(!coll.remoteId().isEmpty()); + if (!job->requestedItems().isEmpty()) { + // Requesting items + for (const Item &item : job->requestedItems()) { + const Collection coll = item.parentCollection(); + Q_ASSERT(!coll.remoteId().isEmpty()); + + } + } else { + // Requesting an entire collection + Q_ASSERT(!job->collection().remoteId().isEmpty()); } } diff --git a/resources/shared/filestore/itemfetchjob.h b/resources/shared/filestore/itemfetchjob.h --- a/resources/shared/filestore/itemfetchjob.h +++ b/resources/shared/filestore/itemfetchjob.h @@ -54,6 +54,8 @@ Item item() const; + Item::List requestedItems() const; + void setFetchScope(const ItemFetchScope &fetchScope); ItemFetchScope &fetchScope(); diff --git a/resources/shared/filestore/itemfetchjob.cpp b/resources/shared/filestore/itemfetchjob.cpp --- a/resources/shared/filestore/itemfetchjob.cpp +++ b/resources/shared/filestore/itemfetchjob.cpp @@ -30,7 +30,8 @@ public: ItemFetchScope mFetchScope; - Item::List mItems; + Item::List mRequestedItems; + Item::List mResultItems; Collection mCollection; Item mItem; @@ -55,7 +56,7 @@ FileStore::ItemFetchJob::ItemFetchJob(const Item::List &items, FileStore::AbstractJobSession *session) : FileStore::Job(session), d(new Private()) { - d->mItems = items; + d->mRequestedItems = items; session->addJob(this); } @@ -85,9 +86,14 @@ return d->mFetchScope; } +Item::List FileStore::ItemFetchJob::requestedItems() const +{ + return d->mRequestedItems; +} + Item::List FileStore::ItemFetchJob::items() const { - return d->mItems; + return d->mResultItems; } bool FileStore::ItemFetchJob::accept(FileStore::Job::Visitor *visitor) @@ -97,7 +103,7 @@ void FileStore::ItemFetchJob::handleItemsReceived(const Item::List &items) { - d->mItems << items; + d->mResultItems << items; Q_EMIT itemsReceived(items); }