mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 21:21:00 +01:00
BinaryCacheStore::narFromPath(): Fix unreachable code
When this function is called as a coroutine (e.g. when it's called by `copyStorePath()`), the code after `decompressor->finish()` is never reached because the coroutine is destroyed when the caller reaches the end of the NAR. So put that code in a `LambdaSink` destructor.
This commit is contained in:
parent
d7b6afecdb
commit
7ba84437be
1 changed files with 14 additions and 6 deletions
|
|
@ -418,10 +418,20 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
||||||
{
|
{
|
||||||
auto info = queryPathInfo(storePath).cast<const NarInfo>();
|
auto info = queryPathInfo(storePath).cast<const NarInfo>();
|
||||||
|
|
||||||
LengthSink narSize;
|
uint64_t narSize = 0;
|
||||||
TeeSink tee{sink, narSize};
|
|
||||||
|
|
||||||
auto decompressor = makeDecompressionSink(info->compression, tee);
|
LambdaSink uncompressedSink{
|
||||||
|
[&](std::string_view data) {
|
||||||
|
narSize += data.size();
|
||||||
|
sink(data);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
|
stats.narRead++;
|
||||||
|
// stats.narReadCompressedBytes += nar->size(); // FIXME
|
||||||
|
stats.narReadBytes += narSize;
|
||||||
|
}};
|
||||||
|
|
||||||
|
auto decompressor = makeDecompressionSink(info->compression, uncompressedSink);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getFile(info->url, *decompressor);
|
getFile(info->url, *decompressor);
|
||||||
|
|
@ -431,9 +441,7 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
||||||
|
|
||||||
decompressor->finish();
|
decompressor->finish();
|
||||||
|
|
||||||
stats.narRead++;
|
// Note: don't do anything here because it's never reached if we're called as a coroutine.
|
||||||
// stats.narReadCompressedBytes += nar->size(); // FIXME
|
|
||||||
stats.narReadBytes += narSize.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryCacheStore::queryPathInfoUncached(
|
void BinaryCacheStore::queryPathInfoUncached(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue