diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-11-30 20:53:10 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-11-30 21:55:53 +0000 |
commit | 70a717f7a8feb15d9daf1215e305162b999b6175 (patch) | |
tree | 3413bcf2c90d50b04c10e5f351dc311312fd7886 /src | |
parent | 1a9bfdc4ca0c2786b02801540432badbafa3a811 (diff) |
Nix daemon stream old wopAddToStore
No more buffering in string.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/daemon.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 2eb566080..773794ffc 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -431,25 +431,23 @@ static void performOp(TunnelLogger * logger, ref<Store> store, hashAlgo = parseHashType(hashAlgoRaw); } - StringSink saved; - TeeSource savedNARSource(from, saved); - RetrieveRegularNARSink savedRegular { saved }; - - if (method == FileIngestionMethod::Recursive) { - /* Get the entire NAR dump from the client and save it to - a string so that we can pass it to - addToStoreFromDump(). */ - ParseSink sink; /* null sink; just parse the NAR */ - parseDump(sink, savedNARSource); - } else - parseDump(savedRegular, from); - + auto dumpSource = sinkToSource([&](Sink & saved) { + TeeSource savedNARSource(from, saved); + RetrieveRegularNARSink savedRegular { saved }; + + if (method == FileIngestionMethod::Recursive) { + /* Get the entire NAR dump from the client and save it to + a string so that we can pass it to + addToStoreFromDump(). */ + ParseSink sink; /* null sink; just parse the NAR */ + parseDump(sink, savedNARSource); + } else + parseDump(savedRegular, from); + + if (!savedRegular.regular) throw Error("regular file expected"); + }); logger->startWork(); - if (!savedRegular.regular) throw Error("regular file expected"); - - // FIXME: try to stream directly from `from`. - StringSource dumpSource { *saved.s }; - auto path = store->addToStoreFromDump(dumpSource, baseName, method, hashAlgo); + auto path = store->addToStoreFromDump(*dumpSource, baseName, method, hashAlgo); logger->stopWork(); to << store->printStorePath(path); |