forked from lix-project/lix
Push wopAddToStore old style stream adapters into smaller scopes
This doesn't fix the bug, but makes the code less difficult to read. Also improve the comments, now that it is clear what part is needed in each code path.
This commit is contained in:
parent
70a717f7a8
commit
95157b4e66
|
@ -432,19 +432,26 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto dumpSource = sinkToSource([&](Sink & saved) {
|
auto dumpSource = sinkToSource([&](Sink & saved) {
|
||||||
TeeSource savedNARSource(from, saved);
|
|
||||||
RetrieveRegularNARSink savedRegular { saved };
|
|
||||||
|
|
||||||
if (method == FileIngestionMethod::Recursive) {
|
if (method == FileIngestionMethod::Recursive) {
|
||||||
/* Get the entire NAR dump from the client and save it to
|
/* We parse the NAR dump through into `saved` unmodified,
|
||||||
a string so that we can pass it to
|
so why all this extra work? We still parse the NAR so
|
||||||
addToStoreFromDump(). */
|
that we aren't sending arbitrary data to `saved`
|
||||||
|
unwittingly`, and we know when the NAR ends so we don't
|
||||||
|
consume the rest of `from` and can't parse another
|
||||||
|
command. (We don't trust `addToStoreFromDump` to not
|
||||||
|
eagerly consume the entire stream it's given, past the
|
||||||
|
length of the Nar. */
|
||||||
|
TeeSource savedNARSource(from, saved);
|
||||||
ParseSink sink; /* null sink; just parse the NAR */
|
ParseSink sink; /* null sink; just parse the NAR */
|
||||||
parseDump(sink, savedNARSource);
|
parseDump(sink, savedNARSource);
|
||||||
} else
|
} else {
|
||||||
|
/* Incrementally parse the NAR file, stripping the
|
||||||
|
metadata, and streaming the sole file we expect into
|
||||||
|
`saved`. */
|
||||||
|
RetrieveRegularNARSink savedRegular { saved };
|
||||||
parseDump(savedRegular, from);
|
parseDump(savedRegular, from);
|
||||||
|
if (!savedRegular.regular) throw Error("regular file expected");
|
||||||
if (!savedRegular.regular) throw Error("regular file expected");
|
}
|
||||||
});
|
});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto path = store->addToStoreFromDump(*dumpSource, baseName, method, hashAlgo);
|
auto path = store->addToStoreFromDump(*dumpSource, baseName, method, hashAlgo);
|
||||||
|
|
Loading…
Reference in a new issue