diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-12 23:51:23 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-13 02:15:48 +0000 |
commit | a4e5de1b9d26584615946057430df9e63d842f53 (patch) | |
tree | d671fa1b72a1c884869acadf2f397ce5cf495475 /src/libstore/daemon.cc | |
parent | a0f369aa3fe9f2d223f45123db952ba7889c3c01 (diff) |
Derivations can output "text-hashed" data
In particular, this means that derivations can output derivations. But
that ramification isn't (yet!) useful as we would want, since there is
no way to have a dependent derivation that is itself a dependent
derivation.
Diffstat (limited to 'src/libstore/daemon.cc')
-rw-r--r-- | src/libstore/daemon.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 7ae88b49a..0e2ae4134 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -380,20 +380,23 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->startWork(); auto pathInfo = [&]() { // NB: FramedSource must be out of scope before logger->stopWork(); - ContentAddressMethod contentAddressMethod = parseContentAddressMethod(camStr); + auto [contentAddressMethod, hashType] = parseContentAddressMethod(camStr); FramedSource source(from); // TODO this is essentially RemoteStore::addCAToStore. Move it up to Store. return std::visit(overloaded { - [&](TextHashMethod &_) { + [&](TextHashMethod _) { + if (hashType != htSHA256) + throw UnimplementedError("Only SHA-256 is supported for adding text-hashed data, but '%1' was given", + printHashType(hashType)); // We could stream this by changing Store std::string contents = source.drain(); auto path = store->addTextToStore(name, contents, refs, repair); return store->queryPathInfo(path); }, - [&](FixedOutputHashMethod &fohm) { + [&](FileIngestionMethod fim) { if (!refs.empty()) throw UnimplementedError("cannot yet have refs with flat or nar-hashed data"); - auto path = store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType, repair); + auto path = store->addToStoreFromDump(source, name, fim, hashType, repair); return store->queryPathInfo(path); }, }, contentAddressMethod); |