mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
Fix up BinaryCacheStore::addToStore taking a path
This commit is contained in:
parent
5db83dd771
commit
1832436526
1 changed files with 19 additions and 8 deletions
|
@ -401,19 +401,30 @@ StorePath BinaryCacheStore::addToStore(const string & name, const Path & srcPath
|
||||||
/* FIXME: Make BinaryCacheStore::addToStoreCommon support
|
/* FIXME: Make BinaryCacheStore::addToStoreCommon support
|
||||||
non-recursive+sha256 so we can just use the default
|
non-recursive+sha256 so we can just use the default
|
||||||
implementation of this method in terms of addToStoreFromDump. */
|
implementation of this method in terms of addToStoreFromDump. */
|
||||||
StringSink sink;
|
|
||||||
std::optional<Hash> h;
|
HashSink sink { hashAlgo };
|
||||||
if (method == FileIngestionMethod::Recursive) {
|
if (method == FileIngestionMethod::Recursive) {
|
||||||
dumpPath(srcPath, sink, filter);
|
dumpPath(srcPath, sink, filter);
|
||||||
h = hashString(hashAlgo, *sink.s);
|
|
||||||
} else {
|
} else {
|
||||||
auto s = readFile(srcPath);
|
readFile(srcPath, sink);
|
||||||
dumpString(s, sink);
|
|
||||||
h = hashString(hashAlgo, s);
|
|
||||||
}
|
}
|
||||||
|
auto h = sink.finish().first;
|
||||||
|
|
||||||
auto source = StringSource { *sink.s };
|
auto source = sinkToSource([&](Sink & sink) {
|
||||||
return addToStoreFromDump(source, name, FileIngestionMethod::Recursive, htSHA256, repair);
|
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,
|
StorePath BinaryCacheStore::addTextToStore(const string & name, const string & s,
|
||||||
|
|
Loading…
Reference in a new issue