From 02c311e38b8b9b80814a4e8e582d5c5a56a51056 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 30 Dec 2015 09:32:52 +0100 Subject: Don't expose enabling/disabling of changerecording to resource implementations --- common/genericresource.cpp | 20 ++++++++++++++++++++ common/genericresource.h | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 1af9226..9fbcaaa 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp @@ -370,6 +370,26 @@ void GenericResource::processCommand(int commandId, const QByteArray &data) } } +KAsync::Job GenericResource::synchronizeWithSource() +{ + return KAsync::start([this]() { + Log() << " Synchronizing"; + //Changereplay would deadlock otherwise when trying to open the synchronization store + enableChangeReplay(false); + auto mainStore = QSharedPointer::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly); + auto syncStore = QSharedPointer::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); + synchronizeWithSource(*mainStore, *syncStore).then([this, mainStore, syncStore]() { + Log() << "Done Synchronizing"; + enableChangeReplay(true); + }).exec(); + }); +} + +KAsync::Job GenericResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) +{ + return KAsync::null(); +} + static void waitForDrained(KAsync::Future &f, MessageQueue &queue) { if (queue.isEmpty()) { diff --git a/common/genericresource.h b/common/genericresource.h index 9c8b977..ea68a25 100644 --- a/common/genericresource.h +++ b/common/genericresource.h @@ -44,7 +44,8 @@ public: virtual ~GenericResource(); virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE; - virtual KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE = 0; + virtual KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE; + virtual KAsync::Job synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore); virtual KAsync::Job processAllMessages() Q_DECL_OVERRIDE; virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; @@ -52,6 +53,7 @@ public: static void removeFromDisk(const QByteArray &instanceIdentifier); static qint64 diskUsage(const QByteArray &instanceIdentifier); + private Q_SLOTS: void updateLowerBoundRevision(); -- cgit v1.2.3