diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-07 00:07:57 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-07 00:07:57 +0200 |
commit | 53d571a4ba75474a6d12d0de6b4059c83578e94b (patch) | |
tree | 733a7e66fafd3a0ae747b050427f2d7762bde793 /common/store.cpp | |
parent | b7fc5fa09a90ec383b58d846533b2b38ba7c577e (diff) | |
download | sink-53d571a4ba75474a6d12d0de6b4059c83578e94b.tar.gz sink-53d571a4ba75474a6d12d0de6b4059c83578e94b.zip |
Revert "Error propagation should work now."
This reverts commit b7fc5fa09a90ec383b58d846533b2b38ba7c577e.
Diffstat (limited to 'common/store.cpp')
-rw-r--r-- | common/store.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/store.cpp b/common/store.cpp index 7783f91..0ecdcd2 100644 --- a/common/store.cpp +++ b/common/store.cpp | |||
@@ -259,21 +259,31 @@ 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; | ||
262 | return KAsync::value(resources) | 264 | return KAsync::value(resources) |
263 | .template each([query](const QByteArray &resource) { | 265 | .template each([query, errorFlag](const QByteArray &resource) { |
264 | SinkTrace() << "Synchronizing " << resource; | 266 | SinkTrace() << "Synchronizing " << resource; |
265 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); | 267 | auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); |
266 | resourceAccess->open(); | 268 | resourceAccess->open(); |
267 | return resourceAccess->synchronizeResource(true, false) | 269 | return resourceAccess->synchronizeResource(true, false) |
268 | .addToContext(resourceAccess) | 270 | .addToContext(resourceAccess) |
269 | .then<void>([](const KAsync::Error &error) { | 271 | .then<void>([errorFlag](const KAsync::Error &error) { |
270 | if (error) { | 272 | if (error) { |
273 | *errorFlag = true; | ||
271 | SinkWarning() << "Error during sync."; | 274 | SinkWarning() << "Error during sync."; |
272 | return KAsync::error<void>(error); | 275 | return KAsync::error<void>(error); |
273 | } | 276 | } |
274 | SinkTrace() << "synced."; | 277 | SinkTrace() << "synced."; |
275 | return KAsync::null<void>(); | 278 | return KAsync::null<void>(); |
276 | }); | 279 | }); |
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>(); | ||
277 | }); | 287 | }); |
278 | } | 288 | } |
279 | 289 | ||