From 166aa563ad41c4566c02cff583df612e328d1520 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 20 Jul 2015 20:42:52 +0200 Subject: Deal with non-existing index --- examples/dummyresource/resourcefactory.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'examples/dummyresource') 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) KAsync::Job DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipeline) { return KAsync::start([this, pipeline](KAsync::Future &f) { - auto storage = QSharedPointer::create(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier); - storage->startTransaction(Akonadi2::Storage::ReadOnly); - + //TODO start transaction on index Index uidIndex(Akonadi2::Store::storageLocation(), mResourceInstanceIdentifier + ".index.uid", Akonadi2::Storage::ReadOnly); const auto data = DummyStore::instance().data(); for (auto it = data.constBegin(); it != data.constEnd(); it++) { bool isNew = true; - if (storage->exists()) { - uidIndex.lookup(it.key().toLatin1(), [&](const QByteArray &value) { - isNew = false; - }, - [](const Index::Error &error) { - Warning() << "Error in index: " << error.message; - }); - } + uidIndex.lookup(it.key().toLatin1(), [&](const QByteArray &value) { + isNew = false; + }, + [](const Index::Error &error) { + if (error.code != Index::IndexNotAvailable) { + Warning() << "Error in uid index: " << error.message; + } + }); if (isNew) { m_fbb.Clear(); @@ -117,7 +115,6 @@ KAsync::Job DummyResource::synchronizeWithSource(Akonadi2::Pipeline *pipel //TODO diff and create modification if necessary } } - storage->abortTransaction(); //TODO find items to remove f.setFinished(); }); -- cgit v1.2.3