mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 13:11:00 +01:00
Merge pull request #14643 from NixOS/binary-cache-nar-from-path
BinaryCacheStore::narFromPath(): Fix unreachable code
This commit is contained in:
commit
2e262c6685
2 changed files with 28 additions and 11 deletions
|
|
@ -418,10 +418,20 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
|||
{
|
||||
auto info = queryPathInfo(storePath).cast<const NarInfo>();
|
||||
|
||||
LengthSink narSize;
|
||||
TeeSink tee{sink, narSize};
|
||||
uint64_t narSize = 0;
|
||||
|
||||
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 {
|
||||
getFile(info->url, *decompressor);
|
||||
|
|
@ -431,9 +441,7 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink)
|
|||
|
||||
decompressor->finish();
|
||||
|
||||
stats.narRead++;
|
||||
// stats.narReadCompressedBytes += nar->size(); // FIXME
|
||||
stats.narReadBytes += narSize.length;
|
||||
// Note: don't do anything here because it's never reached if we're called as a coroutine.
|
||||
}
|
||||
|
||||
void BinaryCacheStore::queryPathInfoUncached(
|
||||
|
|
|
|||
|
|
@ -447,18 +447,27 @@ struct LengthSource : Source
|
|||
*/
|
||||
struct LambdaSink : Sink
|
||||
{
|
||||
typedef std::function<void(std::string_view data)> lambda_t;
|
||||
typedef std::function<void(std::string_view data)> data_t;
|
||||
typedef std::function<void()> cleanup_t;
|
||||
|
||||
lambda_t lambda;
|
||||
data_t dataFun;
|
||||
cleanup_t cleanupFun;
|
||||
|
||||
LambdaSink(const lambda_t & lambda)
|
||||
: lambda(lambda)
|
||||
LambdaSink(
|
||||
const data_t & dataFun, const cleanup_t & cleanupFun = []() {})
|
||||
: dataFun(dataFun)
|
||||
, cleanupFun(cleanupFun)
|
||||
{
|
||||
}
|
||||
|
||||
~LambdaSink()
|
||||
{
|
||||
cleanupFun();
|
||||
}
|
||||
|
||||
void operator()(std::string_view data) override
|
||||
{
|
||||
lambda(data);
|
||||
dataFun(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue