Commit c0dd38fb authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Avoid passing empty entity sets to ProtocolHelper

The methods there tend to throw Exceptions in such situations.
parent adb5b8c5
......@@ -118,11 +118,16 @@ void ItemCreateJob::doStart()
cmd.setAddedFlags(d->mItem.d_func()->mAddedFlags);
cmd.setRemovedFlags(d->mItem.d_func()->mDeletedFlags);
}
if (d->mItem.d_func()->mTagsOverwritten || !merge) {
if (!d->mItem.d_func()->mAddedTags.isEmpty() && (d->mItem.d_func()->mTagsOverwritten || !merge)) {
cmd.setTags(ProtocolHelper::entitySetToScope(d->mItem.d_func()->mAddedTags));
} else {
cmd.setAddedTags(ProtocolHelper::entitySetToScope(d->mItem.d_func()->mAddedTags));
cmd.setRemovedTags(ProtocolHelper::entitySetToScope(d->mItem.d_func()->mDeletedTags));
if (!d->mItem.d_func()->mAddedTags.isEmpty()) {
cmd.setAddedTags(ProtocolHelper::entitySetToScope(d->mItem.d_func()->mAddedTags));
}
if (!d->mItem.d_func()->mDeletedTags.isEmpty()) {
cmd.setRemovedTags(ProtocolHelper::entitySetToScope(d->mItem.d_func()->mDeletedTags));
}
}
cmd.setCollection(ProtocolHelper::entityToScope(d->mCollection));
......
......@@ -171,8 +171,8 @@ void ItemFetchJob::doStart()
try {
d->sendCommand(Protocol::FetchItemsCommand(
ProtocolHelper::entitySetToScope(d->mRequestedItems),
Scope itemScope(d->mRequestedItems.isEmpty() ? ImapSet::all() : ProtocolHelper::entitySetToScope(d->mRequestedItems));
d->sendCommand(Protocol::FetchItemsCommand(itemScope,
ProtocolHelper::commandContextToProtocol(d->mCollection, d->mTag, d->mRequestedItems),
ProtocolHelper::itemFetchScopeToProtocol(d->mFetchScope)));
} catch (const Akonadi::Exception &e) {
......
......@@ -138,7 +138,7 @@ public:
Container<T> objects(_objects);
std::sort(objects.begin(), objects.end(), boost::bind(&T::id, _1) < boost::bind(&T::id, _2));
if (objects.first().isValid()) {
if (objects.at(0).isValid()) {
QVector<typename T::Id> uids;
uids.reserve(objects.size());
for (const T &object : objects) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment