Apply suggestions from code review

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
John Ericson 2020-07-20 11:29:46 -04:00 committed by GitHub
parent 68dfb8c6ae
commit ac2fc7ba1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,7 +234,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
TeeSink sinkIfNar { narHashSink, caHashSink }; TeeSink sinkIfNar { narHashSink, caHashSink };
/* We use the tee sink if we need to hash he nar twice */ /* We use the tee sink if we need to hash the nar twice */
auto & sink = method == FileIngestionMethod::Recursive && hashAlgo != htSHA256 auto & sink = method == FileIngestionMethod::Recursive && hashAlgo != htSHA256
? static_cast<Sink &>(sinkIfNar) ? static_cast<Sink &>(sinkIfNar)
: narHashSink; : narHashSink;
@ -250,7 +250,11 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
? fileSink ? fileSink
: blank; : blank;
parseDump(parseSink, tapped); parseDump(
parseSink,
method == FileIngestionMethod::Recursive && hashAlgo == htSHA256
? *fileSource // don't need to hash twice if we just can use the `narHash` twice
: tapped);
auto [narHash, narSize] = narHashSink.finish(); auto [narHash, narSize] = narHashSink.finish();