aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build/substitution-goal.cc12
-rw-r--r--src/libstore/store-api.cc2
-rw-r--r--src/libutil/serialise.cc15
-rw-r--r--src/libutil/serialise.hh6
4 files changed, 18 insertions, 17 deletions
diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc
index d8d9ba283..cc4cb3c8c 100644
--- a/src/libstore/build/substitution-goal.cc
+++ b/src/libstore/build/substitution-goal.cc
@@ -217,6 +217,7 @@ void PathSubstitutionGoal::tryToRun()
promise = std::promise<void>();
thr = std::thread([this]() {
+ auto & fetchPath = subPath ? *subPath : storePath;
try {
ReceiveInterrupts receiveInterrupts;
@@ -226,10 +227,17 @@ void PathSubstitutionGoal::tryToRun()
Activity act(*logger, actSubstitute, Logger::Fields{worker.store.printStorePath(storePath), sub->getUri()});
PushActivity pact(act.id);
- copyStorePath(*sub, worker.store,
- subPath ? *subPath : storePath, repair, sub->isTrusted ? NoCheckSigs : CheckSigs);
+ copyStorePath(
+ *sub, worker.store, fetchPath, repair, sub->isTrusted ? NoCheckSigs : CheckSigs
+ );
promise.set_value();
+ } catch (const EndOfFile &) {
+ promise.set_exception(std::make_exception_ptr(EndOfFile(
+ "NAR for '%s' fetched from '%s' is incomplete",
+ sub->printStorePath(fetchPath),
+ sub->getUri()
+ )));
} catch (...) {
promise.set_exception(std::current_exception());
}
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 244ecf256..7c0902978 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -1072,8 +1072,6 @@ void copyStorePath(
});
TeeSink tee { sink, progressSink };
srcStore.narFromPath(storePath, tee);
- }, [&]() {
- throw EndOfFile("NAR for '%s' fetched from '%s' is incomplete", srcStore.printStorePath(storePath), srcStore.getUri());
});
dstStore.addToStore(*info, *source, repair, checkSigs);
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index 3a8a01f16..80b111f08 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -266,20 +266,17 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
}
-std::unique_ptr<Source> sinkToSource(
- std::function<void(Sink &)> fun,
- std::function<void()> eof)
+std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun)
{
struct SinkToSource : Source
{
typedef boost::coroutines2::coroutine<std::string> coro_t;
std::function<void(Sink &)> fun;
- std::function<void()> eof;
std::optional<coro_t::pull_type> coro;
- SinkToSource(std::function<void(Sink &)> fun, std::function<void()> eof)
- : fun(fun), eof(eof)
+ SinkToSource(std::function<void(Sink &)> fun)
+ : fun(fun)
{
}
@@ -298,7 +295,9 @@ std::unique_ptr<Source> sinkToSource(
});
}
- if (!*coro) { eof(); abort(); }
+ if (!*coro) {
+ throw EndOfFile("coroutine has finished");
+ }
if (pos == cur.size()) {
if (!cur.empty()) {
@@ -317,7 +316,7 @@ std::unique_ptr<Source> sinkToSource(
}
};
- return std::make_unique<SinkToSource>(fun, eof);
+ return std::make_unique<SinkToSource>(fun);
}
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh
index c9294ba2d..0632e3109 100644
--- a/src/libutil/serialise.hh
+++ b/src/libutil/serialise.hh
@@ -338,11 +338,7 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun);
* Convert a function that feeds data into a Sink into a Source. The
* Source executes the function as a coroutine.
*/
-std::unique_ptr<Source> sinkToSource(
- std::function<void(Sink &)> fun,
- std::function<void()> eof = []() {
- throw EndOfFile("coroutine has finished");
- });
+std::unique_ptr<Source> sinkToSource(std::function<void(Sink &)> fun);
void writePadding(size_t len, Sink & sink);