mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
* Store the size of a store path in the database (to be precise, the
size of the NAR serialisation of the path, i.e., `nix-store --dump PATH'). This is useful for Hydra.
This commit is contained in:
parent
fb9368b5a0
commit
a3883cbd28
16 changed files with 144 additions and 91 deletions
|
@ -286,12 +286,14 @@ Hash hashFile(HashType ht, const Path & path)
|
|||
HashSink::HashSink(HashType ht) : ht(ht)
|
||||
{
|
||||
ctx = new Ctx;
|
||||
bytes = 0;
|
||||
start(ht, *ctx);
|
||||
}
|
||||
|
||||
HashSink::HashSink(const HashSink & h)
|
||||
{
|
||||
ht = h.ht;
|
||||
bytes = h.bytes;
|
||||
ctx = new Ctx;
|
||||
*ctx = *h.ctx;
|
||||
}
|
||||
|
@ -304,18 +306,20 @@ HashSink::~HashSink()
|
|||
void HashSink::operator ()
|
||||
(const unsigned char * data, unsigned int len)
|
||||
{
|
||||
bytes += len;
|
||||
update(ht, *ctx, data, len);
|
||||
}
|
||||
|
||||
Hash HashSink::finish()
|
||||
HashResult HashSink::finish()
|
||||
{
|
||||
Hash hash(ht);
|
||||
nix::finish(ht, *ctx, hash.hash);
|
||||
return hash;
|
||||
return HashResult(hash, bytes);
|
||||
}
|
||||
|
||||
|
||||
Hash hashPath(HashType ht, const Path & path, PathFilter & filter)
|
||||
HashResult hashPath(
|
||||
HashType ht, const Path & path, PathFilter & filter)
|
||||
{
|
||||
HashSink sink(ht);
|
||||
dumpPath(path, sink, filter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue