diff options
Diffstat (limited to 'common/store.cpp')
-rw-r--r-- | common/store.cpp | 31 |
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 | ||
256 | static 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 | |||
256 | KAsync::Job<void> Store::synchronize(const Sink::Query &query) | 272 | KAsync::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) | |||
261 | KAsync::Job<void> Store::synchronize(const Sink::SyncScope &scope) | 277 | KAsync::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 | ||