libstore: asyncify Store::importPaths
Change-Id: Ic330b9213209fd7d3cccf90af7f3d6b41aede9b5
This commit is contained in:
@@ -716,7 +716,7 @@ static void opImport(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
||||
|
||||
FdSource source(STDIN_FILENO);
|
||||
auto paths = store->importPaths(source, NoCheckSigs);
|
||||
auto paths = aio.blockOn(store->importPaths(source, NoCheckSigs));
|
||||
|
||||
for (auto & i : paths)
|
||||
cout << fmt("%s\n", store->printStorePath(i)) << std::flush;
|
||||
@@ -910,7 +910,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
|
||||
case ServeProto::Command::ImportPaths: {
|
||||
if (!writeAllowed) throw Error("importing paths is not allowed");
|
||||
store->importPaths(in, NoCheckSigs); // FIXME: should we skip sig checking?
|
||||
aio.blockOn(store->importPaths(in, NoCheckSigs)); // FIXME: should we skip sig checking?
|
||||
out << 1; // indicate success
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ void Store::exportPath(const StorePath & path, Sink & sink)
|
||||
<< 0;
|
||||
}
|
||||
|
||||
StorePaths Store::importPaths(Source & source, CheckSigsFlag checkSigs)
|
||||
{
|
||||
kj::Promise<Result<StorePaths>> Store::importPaths(Source & source, CheckSigsFlag checkSigs)
|
||||
try {
|
||||
StorePaths res;
|
||||
while (true) {
|
||||
auto n = readNum<uint64_t>(source);
|
||||
@@ -91,7 +91,9 @@ StorePaths Store::importPaths(Source & source, CheckSigsFlag checkSigs)
|
||||
res.push_back(info.path);
|
||||
}
|
||||
|
||||
return res;
|
||||
co_return res;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -796,7 +796,8 @@ public:
|
||||
* Nix store. Optionally, the contents of the NARs are preloaded
|
||||
* into the specified FS accessor to speed up subsequent access.
|
||||
*/
|
||||
StorePaths importPaths(Source & source, CheckSigsFlag checkSigs = CheckSigs);
|
||||
kj::Promise<Result<StorePaths>>
|
||||
importPaths(Source & source, CheckSigsFlag checkSigs = CheckSigs);
|
||||
|
||||
struct Stats
|
||||
{
|
||||
|
||||
@@ -207,7 +207,7 @@ void importPaths(int fd, int dontCheckSigs)
|
||||
PPCODE:
|
||||
try {
|
||||
FdSource source(fd);
|
||||
store()->importPaths(source, dontCheckSigs ? NoCheckSigs : CheckSigs);
|
||||
aio().blockOn(store()->importPaths(source, dontCheckSigs ? NoCheckSigs : CheckSigs));
|
||||
} catch (Error & e) {
|
||||
croak("%s", e.what());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user