aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-05-01 20:10:00 +0200
committereldritch horrors <pennae@lix.systems>2024-07-06 12:36:37 +0200
commit5af76dee371ea5fa1eb72141370fdf18851d67c7 (patch)
treea51cc0348910a8fce0df02c132efe9a438ddd911 /src/libstore/local-store.cc
parent4162a66cee97ec16c88d991ef9a6d9baa3740053 (diff)
libutil: turn HashModuloSink into a free function
Change-Id: I5878007502fa68c2816a0f4c61f7d0e60bdde702
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 98e4d7efe..757aa21e3 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1887,25 +1887,23 @@ ContentAddress LocalStore::hashCAPath(
const std::string_view pathHash
)
{
- HashModuloSink caSink ( hashType, std::string(pathHash) );
- std::visit(overloaded {
- [&](const TextIngestionMethod &) {
- caSink << readFileSource(path);
+ auto data = std::visit(overloaded {
+ [&](const TextIngestionMethod &) -> GeneratorSource {
+ return GeneratorSource(readFileSource(path));
},
- [&](const FileIngestionMethod & m2) {
+ [&](const FileIngestionMethod & m2) -> GeneratorSource {
switch (m2) {
case FileIngestionMethod::Recursive:
- caSink << dumpPath(path);
- break;
+ return GeneratorSource(dumpPath(path));
case FileIngestionMethod::Flat:
- caSink << readFileSource(path);
- break;
+ return GeneratorSource(readFileSource(path));
}
+ assert(false);
},
}, method.raw);
return ContentAddress {
.method = method,
- .hash = caSink.finish().first,
+ .hash = computeHashModulo(hashType, std::string(pathHash), data).first,
};
}