summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r--examples/dummyresource/resourcefactory.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index b9123d5..c7a3eef 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -66,22 +66,20 @@ void DummyResource::configurePipeline(Akonadi2::Pipeline *pipeline)
66KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline) 66KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline)
67{ 67{
68 return KAsync::start<void>([this, pipeline](KAsync::Future<void> &f) { 68 return KAsync::start<void>([this, pipeline](KAsync::Future<void> &f) {
69 auto storage = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier); 69 //TODO start transaction on index
70 storage->startTransaction(Akonadi2::Storage::ReadOnly);
71
72 Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); 70 Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly);
73 71
74 const auto data = DummyStore::instance().data(); 72 const auto data = DummyStore::instance().data();
75 for (auto it = data.constBegin(); it != data.constEnd(); it++) { 73 for (auto it = data.constBegin(); it != data.constEnd(); it++) {
76 bool isNew = true; 74 bool isNew = true;
77 if (storage->exists()) { 75 uidIndex.lookup(it.key().toLatin1(), [&](const QByteArray &value) {
78 uidIndex.lookup(it.key().toLatin1(), [&](const QByteArray &value) { 76 isNew = false;
79 isNew = false; 77 },
80 }, 78 [](const Index::Error &error) {
81 [](const Index::Error &error) { 79 if (error.code != Index::IndexNotAvailable) {
82 Warning() << "Error in index: " << error.message; 80 Warning() << "Error in uid index: " << error.message;
83 }); 81 }
84 } 82 });
85 if (isNew) { 83 if (isNew) {
86 m_fbb.Clear(); 84 m_fbb.Clear();
87 85
@@ -117,7 +115,6 @@ KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipel
117 //TODO diff and create modification if necessary 115 //TODO diff and create modification if necessary
118 } 116 }
119 } 117 }
120 storage->abortTransaction();
121 //TODO find items to remove 118 //TODO find items to remove
122 f.setFinished(); 119 f.setFinished();
123 }); 120 });