about summary refs log tree commit diff
path: root/src/libutil/hash.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r--src/libutil/hash.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index bd7e33a48e70..b9e7846992f6 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -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);