summaryrefslogtreecommitdiffstats
path: root/common/store.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-29 00:24:04 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-29 00:24:04 +0100
commit81b459c0f013704e95fb5933525c82a6ca46f13f (patch)
tree79e68dfd923765cf048f1c3e15bc69fa0490b434 /common/store.cpp
parent169ded69825ab7bde01a5afe9dc842aebeb1c42e (diff)
downloadsink-81b459c0f013704e95fb5933525c82a6ca46f13f.tar.gz
sink-81b459c0f013704e95fb5933525c82a6ca46f13f.zip
Cleanup
Diffstat (limited to 'common/store.cpp')
-rw-r--r--common/store.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/common/store.cpp b/common/store.cpp
index 8b8de1f..f91973d 100644
--- a/common/store.cpp
+++ b/common/store.cpp
@@ -253,6 +253,22 @@ KAsync::Job<void> Store::removeDataFromDisk(const QByteArray &identifier)
253 }); 253 });
254} 254}
255 255
256static KAsync::Job<void> synchronize(const QByteArray &resource, const Sink::SyncScope &scope)
257{
258 SinkTrace() << "Synchronizing " << resource;
259 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource));
260 return resourceAccess->synchronizeResource(scope)
261 .addToContext(resourceAccess)
262 .then<void>([](const KAsync::Error &error) {
263 if (error) {
264 SinkWarning() << "Error during sync.";
265 return KAsync::error<void>(error);
266 }
267 SinkTrace() << "synced.";
268 return KAsync::null<void>();
269 });
270}
271
256KAsync::Job<void> Store::synchronize(const Sink::Query &query) 272KAsync::Job<void> Store::synchronize(const Sink::Query &query)
257{ 273{
258 return synchronize(Sink::SyncScope{static_cast<Sink::QueryBase>(query)}); 274 return synchronize(Sink::SyncScope{static_cast<Sink::QueryBase>(query)});
@@ -261,21 +277,10 @@ KAsync::Job<void> Store::synchronize(const Sink::Query &query)
261KAsync::Job<void> Store::synchronize(const Sink::SyncScope &scope) 277KAsync::Job<void> Store::synchronize(const Sink::SyncScope &scope)
262{ 278{
263 auto resources = getResources(scope.getResourceFilter()).keys(); 279 auto resources = getResources(scope.getResourceFilter()).keys();
264 SinkTrace() << "synchronize" << resources; 280 SinkTrace() << "Synchronize" << resources;
265 return KAsync::value(resources) 281 return KAsync::value(resources)
266 .template each([scope](const QByteArray &resource) { 282 .template each([scope](const QByteArray &resource) {
267 SinkTrace() << "Synchronizing " << resource; 283 return synchronize(resource, scope);
268 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource));
269 return resourceAccess->synchronizeResource(scope)
270 .addToContext(resourceAccess)
271 .then<void>([](const KAsync::Error &error) {
272 if (error) {
273 SinkWarning() << "Error during sync.";
274 return KAsync::error<void>(error);
275 }
276 SinkTrace() << "synced.";
277 return KAsync::null<void>();
278 });
279 }); 284 });
280} 285}
281 286