Commit 038c604a authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

IMAP: switch to GID-based merge when the Collection can contain something else than emails

In order to fix the recurrent multiple-merge-candidates issue which was breaking
ItemSync, ItemSync switched to RID-based merging, which is way more reliable.
However in some cases the IMAP resource still wants to use GID-based merging,
because RID might not be stable enough.

(cherry picked from commit 93a2baac)
parent 59bfb199
......@@ -54,7 +54,7 @@ include(ECMInstallIcons)
set(KF5_VERSION "5.12.0")
set(QT_REQUIRED_VERSION "5.4.0")
set(KDEPIMLIBS_LIB_VERSION "4.88.0")
set(KDEPIMLIBS_LIB_VERSION "4.89.0")
set(KDEPIMRUNTIME_LIB_VERSION "${KDEPIM_RUNTIME_VERSION_NUMBER}")
set(KDEPIMRUNTIME_LIB_SOVERSION "5")
......
......@@ -27,7 +27,8 @@ Q_DECLARE_METATYPE(TagListAndMembers);
DummyResourceState::DummyResourceState()
: m_automaticExpunge(true), m_subscriptionEnabled(true),
m_disconnectedMode(true), m_intervalCheckTime(-1)
m_disconnectedMode(true), m_intervalCheckTime(-1),
m_mergeMode(Akonadi::ItemSync::RIDMerge)
{
qRegisterMetaType<QList<qint64> >();
qRegisterMetaType<QVector<qint64> >();
......@@ -428,6 +429,11 @@ int DummyResourceState::batchSize() const
return 10;
}
void DummyResourceState::setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode)
{
m_mergeMode = mergeMode;
}
MessageHelper::Ptr DummyResourceState::messageHelper() const
{
return MessageHelper::Ptr(new MessageHelper());
......
......@@ -143,6 +143,7 @@ public:
virtual void showInformationDialog(const QString &message, const QString &title, const QString &dontShowAgainName);
virtual int batchSize() const;
virtual void setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode);
virtual MessageHelper::Ptr messageHelper() const;
......@@ -163,6 +164,8 @@ private:
int m_intervalCheckTime;
QChar m_separator;
Akonadi::ItemSync::MergeMode m_mergeMode;
Akonadi::Collection m_collection;
Akonadi::Item::List m_items;
......
......@@ -362,3 +362,8 @@ void ResourceState::relationsRetrieved(const Akonadi::Relation::List &relations)
{
m_resource->relationsRetrieved(relations);
}
void ResourceState::setItemMergingMode(Akonadi::ItemSync::MergeMode mode)
{
m_resource->setItemMergingMode(mode);
}
\ No newline at end of file
......@@ -153,6 +153,8 @@ public:
MessageHelper::Ptr messageHelper() const Q_DECL_OVERRIDE;
void setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode);
private:
ImapResourceBase *m_resource;
const TaskArguments m_arguments;
......
......@@ -26,6 +26,7 @@
#include <Collection>
#include <Item>
#include <ItemSync>
#include <kimap/listjob.h>
......@@ -125,6 +126,8 @@ public:
virtual Akonadi::Relation::List addedRelations() const = 0;
virtual Akonadi::Relation::List removedRelations() const = 0;
virtual void setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode) = 0;
};
#endif
......@@ -591,3 +591,8 @@ KIMAP::Acl::Rights ResourceTask::myRights(const Akonadi::Collection &col)
}
return KIMAP::Acl::None;
}
void ResourceTask::setItemMergingMode(Akonadi::ItemSync::MergeMode mode)
{
m_resource->setItemMergingMode(mode);
}
......@@ -140,6 +140,7 @@ protected:
virtual bool serverSupportsCondstore() const;
int batchSize() const;
void setItemMergingMode(Akonadi::ItemSync::MergeMode mode);
ResourceStateInterface::Ptr resourceState();
......
......@@ -89,6 +89,16 @@ void RetrieveItemsTask::doStart(KIMAP::Session *session)
m_session = session;
const Akonadi::Collection col = collection();
// Only with emails we can be sure that RID is persistent and thus we can use
// it for merging. For other potential content types (like Kolab events etc.)
// use GID instead.
QStringList cts = col.contentMimeTypes();
cts.removeOne(Akonadi::Collection::mimeType());
cts.removeOne(KMime::Message::mimeType());
if (!cts.isEmpty()) {
setItemMergingMode(Akonadi::ItemSync::GIDMerge);
}
if (m_fetchMissingBodies && col.cachePolicy()
.localParts().contains(QLatin1String(Akonadi::MessagePart::Body))) { //disconnected mode, make sure we really have the body cached
......
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