Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,19 @@ static void performOp(
logger->startWork();
{
FramedSource source(conn.from);
store->addMultipleToStore(source, RepairFlag{repair}, dontCheckSigs ? NoCheckSigs : CheckSigs);
auto expected = readNum<uint64_t>(source);
for (uint64_t i = 0; i < expected; ++i) {
auto info = WorkerProto::Serialise<ValidPathInfo>::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;
Expand Down
2 changes: 0 additions & 2 deletions src/libstore/include/nix/store/remote-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/libstore/include/nix/store/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
20 changes: 9 additions & 11 deletions src/libstore/remote-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 0 additions & 22 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -270,25 +267,6 @@ void Store::addMultipleToStore(PathsSource && pathsToCopy, Activity & act, Repai
});
}

void Store::addMultipleToStore(Source & source, RepairFlag repair, CheckSigsFlag checkSigs)
{
auto expected = readNum<uint64_t>(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<ValidPathInfo>::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
Expand Down
Loading