aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-26 04:56:29 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-26 04:56:29 +0000
commit1832436526307ac92baec0146b89e9a5cf3aca35 (patch)
treeb3020277f802278f79431faafcc06451b66bffc3 /src/libstore
parent5db83dd771b92bcacb0cd4dea7d4e06f767769ca (diff)
Fix up BinaryCacheStore::addToStore taking a path
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/binary-cache-store.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index a3a73fe27..b34b10fd1 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -401,19 +401,30 @@ StorePath BinaryCacheStore::addToStore(const string & name, const Path & srcPath
/* FIXME: Make BinaryCacheStore::addToStoreCommon support
non-recursive+sha256 so we can just use the default
implementation of this method in terms of addToStoreFromDump. */
- StringSink sink;
- std::optional<Hash> h;
+
+ HashSink sink { hashAlgo };
if (method == FileIngestionMethod::Recursive) {
dumpPath(srcPath, sink, filter);
- h = hashString(hashAlgo, *sink.s);
} else {
- auto s = readFile(srcPath);
- dumpString(s, sink);
- h = hashString(hashAlgo, s);
+ readFile(srcPath, sink);
}
+ auto h = sink.finish().first;
- auto source = StringSource { *sink.s };
- return addToStoreFromDump(source, name, FileIngestionMethod::Recursive, htSHA256, repair);
+ auto source = sinkToSource([&](Sink & sink) {
+ dumpPath(srcPath, sink, filter);
+ });
+ return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
+ ValidPathInfo info {
+ makeFixedOutputPath(method, h, name),
+ nar.first,
+ };
+ info.narSize = nar.second;
+ info.ca = FixedOutputHash {
+ .method = method,
+ .hash = h,
+ };
+ return info;
+ })->path;
}
StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s,