From f4f6d1d8e24a092422fcec601e21683179b735c9 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 24 Mar 2024 00:44:57 +0100 Subject: libutil: convert readFileSource to a generator Change-Id: I5f92b15fd367d46eb047d74ab6e317b4f51a46d3 --- src/libstore/store-api.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/libstore/store-api.cc') diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 2dad1f5f6..683da1129 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -275,13 +275,11 @@ StorePath Store::addToStore( const StorePathSet & references) { Path srcPath(absPath(_srcPath)); - auto source = sinkToSource([&](Sink & sink) { - if (method == FileIngestionMethod::Recursive) - sink << dumpPath(srcPath, filter); - else - readFileSource(srcPath)->drainInto(sink); - }); - return addToStoreFromDump(*source, name, method, hashAlgo, repair, references); + auto source = GeneratorSource{ + method == FileIngestionMethod::Recursive ? dumpPath(srcPath, filter).decay() + : readFileSource(srcPath) + }; + return addToStoreFromDump(source, name, method, hashAlgo, repair, references); } void Store::addMultipleToStore( -- cgit v1.2.3