diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index f1ef81ffd95a..08802e953ed1 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -510,7 +510,19 @@ static void performOp( logger->startWork(); { FramedSource source(conn.from); - store->addMultipleToStore(source, RepairFlag{repair}, dontCheckSigs ? NoCheckSigs : CheckSigs); + auto expected = readNum(source); + for (uint64_t i = 0; i < expected; ++i) { + auto info = WorkerProto::Serialise::read( + *store, + WorkerProto::ReadConn{ + .from = source, + .version = {.number = {.major = 1, .minor = 16}}, + }); + info.ultimate = false; + EnsureRead wrapper{source, info.narSize}; + store->addToStore(info, wrapper, RepairFlag{repair}, dontCheckSigs ? NoCheckSigs : CheckSigs); + wrapper.finish(); + } } logger->stopWork(); break; diff --git a/src/libstore/include/nix/store/remote-store.hh b/src/libstore/include/nix/store/remote-store.hh index 806aafadfa85..57beb9135f7a 100644 --- a/src/libstore/include/nix/store/remote-store.hh +++ b/src/libstore/include/nix/store/remote-store.hh @@ -100,8 +100,6 @@ struct RemoteStore : public virtual Store, public virtual GcStore, public virtua void addToStore(const ValidPathInfo & info, Source & nar, RepairFlag repair, CheckSigsFlag checkSigs) override; - void addMultipleToStore(Source & source, RepairFlag repair, CheckSigsFlag checkSigs) override; - void addMultipleToStore(PathsSource && pathsToCopy, Activity & act, RepairFlag repair, CheckSigsFlag checkSigs) override; diff --git a/src/libstore/include/nix/store/store-api.hh b/src/libstore/include/nix/store/store-api.hh index d6da94d82b5a..97251eaee9c2 100644 --- a/src/libstore/include/nix/store/store-api.hh +++ b/src/libstore/include/nix/store/store-api.hh @@ -652,8 +652,6 @@ public: /** * Import multiple paths into the store. */ - virtual void addMultipleToStore(Source & source, RepairFlag repair = NoRepair, CheckSigsFlag checkSigs = CheckSigs); - virtual void addMultipleToStore( PathsSource && pathsToCopy, Activity & act, RepairFlag repair = NoRepair, CheckSigsFlag checkSigs = CheckSigs); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index c261e3384a61..2562e65d88e1 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -458,6 +458,13 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, Repair void RemoteStore::addMultipleToStore( PathsSource && pathsToCopy, Activity & act, RepairFlag repair, CheckSigsFlag checkSigs) { + if (getConnection()->protoVersion < WorkerProto::Version{.number = {1, 32}}) { + Store::addMultipleToStore(std::move(pathsToCopy), act, repair, checkSigs); + return; + } + + auto conn(getConnection()); + // `addMultipleToStore` is single threaded size_t bytesExpected = 0; for (auto & [pathInfo, _] : pathsToCopy) { @@ -486,17 +493,8 @@ void RemoteStore::addMultipleToStore( } }); - addMultipleToStore(*source, repair, checkSigs); -} - -void RemoteStore::addMultipleToStore(Source & source, RepairFlag repair, CheckSigsFlag checkSigs) -{ - if (getConnection()->protoVersion >= WorkerProto::Version{.number = {1, 32}}) { - auto conn(getConnection()); - conn->to << WorkerProto::Op::AddMultipleToStore << repair << !checkSigs; - conn.withFramedSink([&](Sink & sink) { source.drainInto(sink); }); - } else - Store::addMultipleToStore(source, repair, checkSigs); + conn->to << WorkerProto::Op::AddMultipleToStore << repair << !checkSigs; + conn.withFramedSink([&](Sink & sink) { source->drainInto(sink); }); } void RemoteStore::registerDrvOutput(const Realisation & info) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 69d8860c5373..f465c959c8dd 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -15,9 +15,6 @@ #include "nix/util/callback.hh" #include "nix/util/git.hh" #include "nix/util/posix-source-accessor.hh" -// FIXME this should not be here, see TODO below on -// `addMultipleToStore`. -#include "nix/store/worker-protocol.hh" #include "nix/util/signals.hh" #include "nix/util/environment-variables.hh" #include "nix/util/file-system.hh" @@ -270,25 +267,6 @@ void Store::addMultipleToStore(PathsSource && pathsToCopy, Activity & act, Repai }); } -void Store::addMultipleToStore(Source & source, RepairFlag repair, CheckSigsFlag checkSigs) -{ - auto expected = readNum(source); - for (uint64_t i = 0; i < expected; ++i) { - // FIXME we should not be using the worker protocol here, let - // alone the worker protocol with a hard-coded version! - auto info = WorkerProto::Serialise::read( - *this, - WorkerProto::ReadConn{ - .from = source, - .version = {.number = {.major = 1, .minor = 16}}, - }); - info.ultimate = false; - EnsureRead wrapper{source, info.narSize}; - addToStore(info, wrapper, repair, checkSigs); - wrapper.finish(); - } -} - /* The aim of this function is to compute in one pass the correct ValidPathInfo for the files that we are trying to add to the store. To accomplish that in one