diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 17:53:33 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-06 17:53:33 +0200 |
commit | b7fc5fa09a90ec383b58d846533b2b38ba7c577e (patch) | |
tree | 6f0bb6085f3398d5faa0b94bf2bcf37ba6fece82 | |
parent | 87695f52d5ac627cdd710f37c275fccdf920af0b (diff) | |
download | sink-b7fc5fa09a90ec383b58d846533b2b38ba7c577e.tar.gz sink-b7fc5fa09a90ec383b58d846533b2b38ba7c577e.zip |
Error propagation should work now.
-rw-r--r-- | common/store.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/common/store.cpp b/common/store.cpp index 0ecdcd2..7783f91 100644 --- a/common/store.cpp +++ b/common/store.cpp | |||
@@ -259,31 +259,21 @@ KAsync::Job<void> Store::synchronize(const Sink::Query &query) | |||
259 | { | 259 | { |
260 | auto resources = getResources(query).keys(); | 260 | auto resources = getResources(query).keys(); |
261 | SinkTrace() << "synchronize" << resources; | 261 | SinkTrace() << "synchronize" << resources; |
262 | //FIXME only necessary because each doesn't propagate errors | ||
263 | auto errorFlag = new bool; | ||
264 | return KAsync::value(resources) | 262 | return KAsync::value(resources) |
265 | .template each([query, errorFlag](const QByteArray &resource) { | 263 | .template each([query](const QByteArray &resource) { |
266 | SinkTrace() << "Synchronizing " << resource; | 264 | SinkTrace() << "Synchronizing " << resource; |
267 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); | 265 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); |
268 | resourceAccess->open(); | 266 | resourceAccess->open(); |
269 | return resourceAccess->synchronizeResource(true, false) | 267 | return resourceAccess->synchronizeResource(true, false) |
270 | .addToContext(resourceAccess) | 268 | .addToContext(resourceAccess) |
271 | .then<void>([errorFlag](const KAsync::Error &error) { | 269 | .then<void>([](const KAsync::Error &error) { |
272 | if (error) { | 270 | if (error) { |
273 | *errorFlag = true; | ||
274 | SinkWarning() << "Error during sync."; | 271 | SinkWarning() << "Error during sync."; |
275 | return KAsync::error<void>(error); | 272 | return KAsync::error<void>(error); |
276 | } | 273 | } |
277 | SinkTrace() << "synced."; | 274 | SinkTrace() << "synced."; |
278 | return KAsync::null<void>(); | 275 | return KAsync::null<void>(); |
279 | }); | 276 | }); |
280 | }) | ||
281 | .then<void>([errorFlag]() { | ||
282 | if (*errorFlag) { | ||
283 | return KAsync::error<void>("Error during sync."); | ||
284 | } | ||
285 | delete errorFlag; | ||
286 | return KAsync::null<void>(); | ||
287 | }); | 277 | }); |
288 | } | 278 | } |
289 | 279 | ||