sourceToSink(): Throw EndOfFile

This commit is contained in:
Eelco Dolstra 2024-07-22 15:18:58 +02:00
parent 0194f81587
commit 609df83c01
2 changed files with 4 additions and 6 deletions

View file

@ -1245,7 +1245,6 @@ StorePath LocalStore::addToStoreFromDump(
});
try {
got = source.read(dumpBuffer.get() + oldSize, want);
if (!got) break;
} catch (EndOfFile &) {
inMemory = true;
break;

View file

@ -246,9 +246,8 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
LambdaSource source([&](char * out, size_t out_len) {
if (cur.empty()) {
yield();
if (yield.get()) {
return (size_t) 0;
}
if (yield.get())
throw EndOfFile("coroutine has finished");
}
size_t n = std::min(cur.size(), out_len);
@ -271,12 +270,12 @@ std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
void finish() override
{
if (!coro) return;
//if (!*coro) abort();
if (!*coro) abort();
{
CoroutineContext ctx;
(*coro)(true);
}
//if (*coro) abort();
if (*coro) abort();
}
};