diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-11 17:32:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-11 17:32:30 +0200 |
commit | c3a20160d4ff52c8ec288f6a42f7e136064fb493 (patch) | |
tree | 866ff1850a7c160ed39494a989f18aef182d2d2f | |
parent | d6e6cab8b284167a9c8fd30ae669354d8315b3aa (diff) | |
download | sink-c3a20160d4ff52c8ec288f6a42f7e136064fb493.tar.gz sink-c3a20160d4ff52c8ec288f6a42f7e136064fb493.zip |
Replay removals.
Now we just have to avoid removing the revision too early from the
resource.
-rw-r--r-- | common/clientapi.h | 4 | ||||
-rw-r--r-- | common/entitystorage.cpp | 8 | ||||
-rw-r--r-- | common/facade.h | 7 | ||||
-rw-r--r-- | tests/dummyresourcetest.cpp | 13 |
4 files changed, 21 insertions, 11 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index 04433f8..e467b8f 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -175,9 +175,9 @@ public: | |||
175 | //Potentially move to separate thread as well | 175 | //Potentially move to separate thread as well |
176 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); | 176 | auto facade = FacadeFactory::instance().getFacade<DomainType>(resourceName(resourceIdentifier), resourceIdentifier); |
177 | if (facade) { | 177 | if (facade) { |
178 | facade->remove(domainObject).template then<void>([facade](){}, [](int errorCode, const QString &error) { | 178 | return facade->remove(domainObject).template then<void>([facade](){}, [](int errorCode, const QString &error) { |
179 | Warning() << "Failed to remove"; | 179 | Warning() << "Failed to remove"; |
180 | }).exec().waitForFinished(); | 180 | }); |
181 | } | 181 | } |
182 | return KAsync::error<void>(-1, "Failed to create a facade"); | 182 | return KAsync::error<void>(-1, "Failed to create a facade"); |
183 | } | 183 | } |
diff --git a/common/entitystorage.cpp b/common/entitystorage.cpp index b77b481..b19fe0a 100644 --- a/common/entitystorage.cpp +++ b/common/entitystorage.cpp | |||
@@ -58,7 +58,11 @@ void EntityStorageBase::readEntity(const Akonadi2::Storage::Transaction &transac | |||
58 | auto operation = metadataBuffer->operation(); | 58 | auto operation = metadataBuffer->operation(); |
59 | 59 | ||
60 | auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); | 60 | auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); |
61 | resultCallback(domainObject, operation); | 61 | if (operation == Akonadi2::Operation_Removal) { |
62 | resultCallback(create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)), operation); | ||
63 | } else { | ||
64 | resultCallback(create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)), operation); | ||
65 | } | ||
62 | return false; | 66 | return false; |
63 | }, mBufferType); | 67 | }, mBufferType); |
64 | } | 68 | } |
@@ -124,7 +128,7 @@ ResultSet EntityStorageBase::getResultSet(const Akonadi2::Query &query, Akonadi2 | |||
124 | const qint64 topRevision = Akonadi2::Storage::maxRevision(transaction); | 128 | const qint64 topRevision = Akonadi2::Storage::maxRevision(transaction); |
125 | QSet<QByteArray> remainingFilters = query.propertyFilter.keys().toSet(); | 129 | QSet<QByteArray> remainingFilters = query.propertyFilter.keys().toSet(); |
126 | ResultSet resultSet; | 130 | ResultSet resultSet; |
127 | const bool initialQuery = (baseRevision == 0); | 131 | const bool initialQuery = (baseRevision == 1); |
128 | if (initialQuery) { | 132 | if (initialQuery) { |
129 | Trace() << "Initial result set update"; | 133 | Trace() << "Initial result set update"; |
130 | resultSet = loadInitialResultSet(query, transaction, remainingFilters); | 134 | resultSet = loadInitialResultSet(query, transaction, remainingFilters); |
diff --git a/common/facade.h b/common/facade.h index 5ed3bde..38388c7 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -54,11 +54,8 @@ public: | |||
54 | { | 54 | { |
55 | //TODO: JOBAPI: that last empty .then should not be necessary | 55 | //TODO: JOBAPI: that last empty .then should not be necessary |
56 | //TODO: remove newRevision | 56 | //TODO: remove newRevision |
57 | if (mLatestRevision == newRevision && mLatestRevision > 0) { | 57 | return queryFunction(mLatestRevision + 1).then<void, qint64>([this](qint64 revision) { |
58 | return KAsync::null<void>(); | 58 | mLatestRevision = revision; |
59 | } | ||
60 | return queryFunction(mLatestRevision).then<void, qint64>([this](qint64 revision) { | ||
61 | mLatestRevision = revision + 1; | ||
62 | }).then<void>([](){}); | 59 | }).then<void>([](){}); |
63 | } | 60 | } |
64 | 61 | ||
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index caf808a..fe3acc9 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -29,7 +29,7 @@ private Q_SLOTS: | |||
29 | removeFromDisk("org.kde.dummy.instance1"); | 29 | removeFromDisk("org.kde.dummy.instance1"); |
30 | removeFromDisk("org.kde.dummy.instance1.userqueue"); | 30 | removeFromDisk("org.kde.dummy.instance1.userqueue"); |
31 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); | 31 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); |
32 | removeFromDisk("org.kde.dummy.instance1.index.uid"); | 32 | removeFromDisk("org.kde.dummy.instance1.event.index.uid"); |
33 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 33 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
34 | } | 34 | } |
35 | 35 | ||
@@ -39,7 +39,7 @@ private Q_SLOTS: | |||
39 | removeFromDisk("org.kde.dummy.instance1"); | 39 | removeFromDisk("org.kde.dummy.instance1"); |
40 | removeFromDisk("org.kde.dummy.instance1.userqueue"); | 40 | removeFromDisk("org.kde.dummy.instance1.userqueue"); |
41 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); | 41 | removeFromDisk("org.kde.dummy.instance1.synchronizerqueue"); |
42 | removeFromDisk("org.kde.dummy.instance1.index.uid"); | 42 | removeFromDisk("org.kde.dummy.instance1.event.index.uid"); |
43 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 43 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); |
44 | QVERIFY(factory); | 44 | QVERIFY(factory); |
45 | } | 45 | } |
@@ -214,6 +214,15 @@ private Q_SLOTS: | |||
214 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 214 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
215 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); | 215 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); |
216 | } | 216 | } |
217 | |||
218 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2, "org.kde.dummy.instance1").exec().waitForFinished(); | ||
219 | |||
220 | //Test remove | ||
221 | { | ||
222 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | ||
223 | result.exec(); | ||
224 | QCOMPARE(result.size(), 0); | ||
225 | } | ||
217 | } | 226 | } |
218 | 227 | ||
219 | }; | 228 | }; |