diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-16 16:28:52 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-16 00:57:42 +0000 |
commit | 5271424d14241ec5cbe7ab3bda85ddeb486cff76 (patch) | |
tree | fc3791a768e419af2fa896f165b083bc968ba105 | |
parent | 4ec87742a196d8ed8f41b41ef039706ce791448d (diff) |
libstore: remove a sinkToSouce from old daemon protocol
this doesn't have a test because this code path is only reached by
clients that predate 2.4, and we really should not be caring about
those any more right now. even the test suite doesn't, and the few
tests that might care are disabled because they will not even work
Change-Id: Id9eb190065138fedb2c7d90c328ff9eb9d97385b
-rw-r--r-- | src/libstore/daemon.cc | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index f7b6a38a1..cae5b54fd 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -453,7 +453,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, hashAlgo = parseHashType(hashAlgoRaw); } - auto dumpSource = sinkToSource([&](Sink & saved) { + GeneratorSource dumpSource{[&]() -> WireFormatGenerator { if (method == FileIngestionMethod::Recursive) { /* We parse the NAR dump through into `saved` unmodified, so why all this extra work? We still parse the NAR so @@ -463,18 +463,35 @@ static void performOp(TunnelLogger * logger, ref<Store> store, command. (We don't trust `addToStoreFromDump` to not eagerly consume the entire stream it's given, past the length of the Nar. */ - saved << copyNAR(from); + co_yield copyNAR(from); } else { /* Incrementally parse the NAR file, stripping the metadata, and streaming the sole file we expect into `saved`. */ - RetrieveRegularNARSink savedRegular { saved }; - parseDump(savedRegular, from); - if (!savedRegular.regular) throw Error("regular file expected"); + auto parser = nar::parse(from); + nar::File * file = nullptr; + while (auto entry = parser.next()) { + file = std::visit( + overloaded{ + [](nar::MetadataString) -> nar::File * { return nullptr; }, + [](nar::MetadataRaw) -> nar::File * { return nullptr; }, + [](nar::File & f) -> nar::File * { return &f; }, + [](auto &) -> nar::File * { throw Error("regular file expected"); }, + }, + *entry + ); + if (file) { + break; + } + } + if (!file) { + throw Error("regular file expected"); + } + co_yield std::move(file->contents); } - }); + }()}; logger->startWork(); - auto path = store->addToStoreFromDump(*dumpSource, baseName, method, hashAlgo); + auto path = store->addToStoreFromDump(dumpSource, baseName, method, hashAlgo); logger->stopWork(); to << store->printStorePath(path); |