libstore: asyncify Store::addMultipleToStore

Change-Id: I6a552fecfef8c32979afdec8caa9cdeaf875b511
This commit is contained in:
eldritch horrors
2025-02-08 17:26:19 +00:00
parent 65edbcc37a
commit 2c52a20dd2
5 changed files with 29 additions and 17 deletions
+2 -2
View File
@@ -515,9 +515,9 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
logger->startWork();
{
FramedSource source(from);
store->addMultipleToStore(source,
aio.blockOn(store->addMultipleToStore(source,
RepairFlag{repair},
dontCheckSigs ? NoCheckSigs : CheckSigs);
dontCheckSigs ? NoCheckSigs : CheckSigs));
}
logger->stopWork();
break;
+12 -6
View File
@@ -489,12 +489,12 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
}
void RemoteStore::addMultipleToStore(
kj::Promise<Result<void>> RemoteStore::addMultipleToStore(
PathsSource & pathsToCopy,
Activity & act,
RepairFlag repair,
CheckSigsFlag checkSigs)
{
try {
auto remoteVersion = getProtocol();
GeneratorSource source{
@@ -516,14 +516,17 @@ void RemoteStore::addMultipleToStore(
}(this, pathsToCopy, remoteVersion)
};
addMultipleToStore(source, repair, checkSigs);
TRY_AWAIT(addMultipleToStore(source, repair, checkSigs));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
void RemoteStore::addMultipleToStore(
kj::Promise<Result<void>> RemoteStore::addMultipleToStore(
Source & source,
RepairFlag repair,
CheckSigsFlag checkSigs)
{
try {
if (GET_PROTOCOL_MINOR(getConnection()->daemonVersion) >= 32) {
auto conn(getConnection());
conn->to
@@ -534,7 +537,10 @@ void RemoteStore::addMultipleToStore(
source.drainInto(sink);
});
} else
Store::addMultipleToStore(source, repair, checkSigs);
TRY_AWAIT(Store::addMultipleToStore(source, repair, checkSigs));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
+2 -2
View File
@@ -91,12 +91,12 @@ public:
void addToStore(const ValidPathInfo & info, Source & nar,
RepairFlag repair, CheckSigsFlag checkSigs) override;
void addMultipleToStore(
kj::Promise<Result<void>> addMultipleToStore(
Source & source,
RepairFlag repair,
CheckSigsFlag checkSigs) override;
void addMultipleToStore(
kj::Promise<Result<void>> addMultipleToStore(
PathsSource & pathsToCopy,
Activity & act,
RepairFlag repair,
+11 -5
View File
@@ -286,12 +286,12 @@ StorePath Store::addToStore(
return addToStoreFromDump(source, name, method, hashAlgo, repair, references);
}
void Store::addMultipleToStore(
kj::Promise<Result<void>> Store::addMultipleToStore(
PathsSource & pathsToCopy,
Activity & act,
RepairFlag repair,
CheckSigsFlag checkSigs)
{
try {
std::atomic<size_t> nrDone{0};
std::atomic<size_t> nrFailed{0};
std::atomic<uint64_t> bytesExpected{0};
@@ -361,13 +361,16 @@ void Store::addMultipleToStore(
nrDone++;
showProgress();
});
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
void Store::addMultipleToStore(
kj::Promise<Result<void>> Store::addMultipleToStore(
Source & source,
RepairFlag repair,
CheckSigsFlag checkSigs)
{
try {
auto remoteVersion = getProtocol();
auto expected = readNum<uint64_t>(source);
@@ -379,6 +382,9 @@ void Store::addMultipleToStore(
info.ultimate = false;
addToStore(info, source, repair, checkSigs);
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
namespace {
@@ -1288,7 +1294,7 @@ try {
});
}
dstStore.addMultipleToStore(pathsToCopy, act, repair, checkSigs);
TRY_AWAIT(dstStore.addMultipleToStore(pathsToCopy, act, repair, checkSigs));
co_return pathsMap;
} catch (...) {
+2 -2
View File
@@ -507,12 +507,12 @@ public:
/**
* Import multiple paths into the store.
*/
virtual void addMultipleToStore(
virtual kj::Promise<Result<void>> addMultipleToStore(
Source & source,
RepairFlag repair = NoRepair,
CheckSigsFlag checkSigs = CheckSigs);
virtual void addMultipleToStore(
virtual kj::Promise<Result<void>> addMultipleToStore(
PathsSource & pathsToCopy,
Activity & act,
RepairFlag repair = NoRepair,