Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
  • Loading branch information
Ericson2314 and edolstra committed Jul 20, 2020
1 parent 68dfb8c commit ac2fc7b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libstore/store-api.cc
Expand Up @@ -234,7 +234,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,

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
? static_cast<Sink &>(sinkIfNar)
: narHashSink;

This comment has been minimized.

Copy link
@Ericson2314

Ericson2314 Jul 20, 2020

Author Member

Ah!, it's only via sink, via tapped, that narHashSink is changed at all.

What I wrote before was the right thing all along.

This comment has been minimized.

Copy link
@Ericson2314

Ericson2314 Jul 20, 2020

Author Member

Silly me for changing it. PR forthcoming with the revert (keeping the typo, adding some comments)

This comment has been minimized.

Copy link
@meditans

meditans Jul 21, 2020

Member

Fixed in #3842

Expand All @@ -250,7 +250,11 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
? fileSink
: 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();

Expand Down

0 comments on commit ac2fc7b

Please sign in to comment.