aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/remote-store.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index d0ce0bce9..2abd3aa51 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -575,6 +575,7 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
Source & dump,
std::string_view name,
ContentAddressMethod caMethod,
+ HashType hashType,
const StorePathSet & references,
RepairFlag repair)
{
@@ -586,7 +587,7 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
conn->to
<< wopAddToStore
<< name
- << caMethod.render();
+ << caMethod.render(hashType);
worker_proto::write(*this, conn->to, references);
conn->to << repair;
@@ -607,25 +608,28 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
std::visit(overloaded {
[&](const TextHashMethod & thm) -> void {
+ if (hashType != htSHA256)
+ throw UnimplementedError("Only SHA-256 is supported for adding text-hashed data, but '%1' was given",
+ printHashType(hashType));
std::string s = dump.drain();
conn->to << wopAddTextToStore << name << s;
worker_proto::write(*this, conn->to, references);
conn.processStderr();
},
- [&](const FixedOutputHashMethod & fohm) -> void {
+ [&](const FileIngestionMethod & fim) -> void {
conn->to
<< wopAddToStore
<< name
- << ((fohm.hashType == htSHA256 && fohm.fileIngestionMethod == FileIngestionMethod::Recursive) ? 0 : 1) /* backwards compatibility hack */
- << (fohm.fileIngestionMethod == FileIngestionMethod::Recursive ? 1 : 0)
- << printHashType(fohm.hashType);
+ << ((hashType == htSHA256 && fim == FileIngestionMethod::Recursive) ? 0 : 1) /* backwards compatibility hack */
+ << (fim == FileIngestionMethod::Recursive ? 1 : 0)
+ << printHashType(hashType);
try {
conn->to.written = 0;
connections->incCapacity();
{
Finally cleanup([&]() { connections->decCapacity(); });
- if (fohm.fileIngestionMethod == FileIngestionMethod::Recursive) {
+ if (fim == FileIngestionMethod::Recursive) {
dump.drainInto(conn->to);
} else {
std::string contents = dump.drain();
@@ -656,7 +660,7 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
StorePath RemoteStore::addToStoreFromDump(Source & dump, std::string_view name,
FileIngestionMethod method, HashType hashType, RepairFlag repair, const StorePathSet & references)
{
- return addCAToStore(dump, name, FixedOutputHashMethod{ .fileIngestionMethod = method, .hashType = hashType }, references, repair)->path;
+ return addCAToStore(dump, name, method, hashType, references, repair)->path;
}
@@ -756,7 +760,7 @@ StorePath RemoteStore::addTextToStore(
RepairFlag repair)
{
StringSource source(s);
- return addCAToStore(source, name, TextHashMethod{}, references, repair)->path;
+ return addCAToStore(source, name, TextHashMethod {}, htSHA256, references, repair)->path;
}
void RemoteStore::registerDrvOutput(const Realisation & info)