From 53d571a4ba75474a6d12d0de6b4059c83578e94b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 7 Oct 2016 00:07:57 +0200 Subject: Revert "Error propagation should work now." This reverts commit b7fc5fa09a90ec383b58d846533b2b38ba7c577e. --- common/store.cpp | 14 ++++++++++++-- 1 file 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 Store::synchronize(const Sink::Query &query) { auto resources = getResources(query).keys(); SinkTrace() << "synchronize" << resources; + //FIXME only necessary because each doesn't propagate errors + auto errorFlag = new bool; return KAsync::value(resources) - .template each([query](const QByteArray &resource) { + .template each([query, errorFlag](const QByteArray &resource) { SinkTrace() << "Synchronizing " << resource; auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource, ResourceConfig::getResourceType(resource)); resourceAccess->open(); return resourceAccess->synchronizeResource(true, false) .addToContext(resourceAccess) - .then([](const KAsync::Error &error) { + .then([errorFlag](const KAsync::Error &error) { if (error) { + *errorFlag = true; SinkWarning() << "Error during sync."; return KAsync::error(error); } SinkTrace() << "synced."; return KAsync::null(); }); + }) + .then([errorFlag]() { + if (*errorFlag) { + return KAsync::error("Error during sync."); + } + delete errorFlag; + return KAsync::null(); }); } -- cgit v1.2.3