Skip to content

Commit

Permalink
Nix daemon stream old wopAddToStore
Browse files Browse the repository at this point in the history
No more buffering in string.
  • Loading branch information
Ericson2314 authored and ElvishJerricco committed Nov 30, 2021
1 parent 49de63f commit 946098a
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,25 +433,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);
Expand Down

0 comments on commit 946098a

Please sign in to comment.