libstore:: asyncify Store::addToStoreFromDump
Change-Id: I6577a157d66765e08530633868d714f70e46891d
This commit is contained in:
@@ -133,7 +133,7 @@ struct PathInputScheme : InputScheme
|
||||
if (!storePath || storePath->name() != "source" || !store->isValidPath(*storePath)) {
|
||||
// FIXME: try to substitute storePath.
|
||||
auto src = GeneratorSource{dumpPathAndGetMtime(absPath, mtime, defaultPathFilter)};
|
||||
storePath = store->addToStoreFromDump(src, "source");
|
||||
storePath = TRY_AWAIT(store->addToStoreFromDump(src, "source"));
|
||||
}
|
||||
input.attrs.insert_or_assign("lastModified", uint64_t(mtime));
|
||||
|
||||
|
||||
@@ -277,12 +277,12 @@ try {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method, HashType hashAlgo, RepairFlag repair, const StorePathSet & references)
|
||||
{
|
||||
try {
|
||||
if (method != FileIngestionMethod::Recursive || hashAlgo != HashType::SHA256)
|
||||
unsupported("addToStoreFromDump");
|
||||
return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
|
||||
co_return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
|
||||
ValidPathInfo info {
|
||||
*this,
|
||||
name,
|
||||
@@ -300,6 +300,8 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
|
||||
info.narSize = nar.second;
|
||||
return info;
|
||||
})->path;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
bool BinaryCacheStore::isValidPathUncached(const StorePath & storePath)
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
kj::Promise<Result<void>> addToStore(const ValidPathInfo & info, Source & narSource,
|
||||
RepairFlag repair, CheckSigsFlag checkSigs) override;
|
||||
|
||||
StorePath addToStoreFromDump(Source & dump, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method, HashType hashAlgo, RepairFlag repair, const StorePathSet & references) override;
|
||||
|
||||
kj::Promise<Result<StorePath>> addToStore(
|
||||
|
||||
@@ -1080,17 +1080,19 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
|
||||
return path;
|
||||
}
|
||||
|
||||
StorePath addToStoreFromDump(
|
||||
kj::Promise<Result<StorePath>> addToStoreFromDump(
|
||||
Source & dump,
|
||||
std::string_view name,
|
||||
FileIngestionMethod method,
|
||||
HashType hashAlgo,
|
||||
RepairFlag repair,
|
||||
const StorePathSet & references) override
|
||||
{
|
||||
auto path = next->addToStoreFromDump(dump, name, method, hashAlgo, repair, references);
|
||||
try {
|
||||
auto path = TRY_AWAIT(next->addToStoreFromDump(dump, name, method, hashAlgo, repair, references));
|
||||
goal.addDependency(path);
|
||||
return path;
|
||||
co_return path;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
box_ptr<Source> narFromPath(const StorePath & path) override
|
||||
|
||||
@@ -427,7 +427,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
return store->queryPathInfo(path);
|
||||
},
|
||||
[&](const FileIngestionMethod & fim) {
|
||||
auto path = store->addToStoreFromDump(source, name, fim, hashType, repair, refs);
|
||||
auto path = aio.blockOn(store->addToStoreFromDump(source, name, fim, hashType, repair, refs));
|
||||
return store->queryPathInfo(path);
|
||||
},
|
||||
}, contentAddressMethod.raw);
|
||||
@@ -498,7 +498,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
};
|
||||
GeneratorSource dumpSource{g()};
|
||||
logger->startWork();
|
||||
auto path = store->addToStoreFromDump(dumpSource, baseName, method, hashAlgo);
|
||||
auto path = aio.blockOn(store->addToStoreFromDump(dumpSource, baseName, method, hashAlgo));
|
||||
logger->stopWork();
|
||||
|
||||
to << store->printStorePath(path);
|
||||
|
||||
@@ -1281,9 +1281,9 @@ try {
|
||||
}
|
||||
|
||||
|
||||
StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> LocalStore::addToStoreFromDump(Source & source0, std::string_view name,
|
||||
FileIngestionMethod method, HashType hashAlgo, RepairFlag repair, const StorePathSet & references)
|
||||
{
|
||||
try {
|
||||
/* For computing the store path. */
|
||||
auto hashSink = std::make_unique<HashSink>(hashAlgo);
|
||||
TeeSource source { source0, *hashSink };
|
||||
@@ -1419,7 +1419,9 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
|
||||
}
|
||||
}
|
||||
|
||||
return dstPath;
|
||||
co_return dstPath;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
kj::Promise<Result<void>> addToStore(const ValidPathInfo & info, Source & source,
|
||||
RepairFlag repair, CheckSigsFlag checkSigs) override;
|
||||
|
||||
StorePath addToStoreFromDump(Source & dump, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method, HashType hashAlgo, RepairFlag repair, const StorePathSet & references) override;
|
||||
|
||||
StorePath addTextToStore(
|
||||
|
||||
@@ -458,10 +458,12 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
||||
}
|
||||
|
||||
|
||||
StorePath RemoteStore::addToStoreFromDump(Source & dump, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> RemoteStore::addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method, HashType hashType, RepairFlag repair, const StorePathSet & references)
|
||||
{
|
||||
return addCAToStore(dump, name, method, hashType, references, repair)->path;
|
||||
try {
|
||||
co_return addCAToStore(dump, name, method, hashType, references, repair)->path;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
/**
|
||||
* Add a content-addressable store path. Does not support references. `dump` will be drained.
|
||||
*/
|
||||
StorePath addToStoreFromDump(Source & dump, std::string_view name,
|
||||
kj::Promise<Result<StorePath>> addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256, RepairFlag repair = NoRepair, const StorePathSet & references = StorePathSet()) override;
|
||||
|
||||
kj::Promise<Result<void>> addToStore(const ValidPathInfo & info, Source & nar,
|
||||
|
||||
@@ -283,7 +283,7 @@ try {
|
||||
method == FileIngestionMethod::Recursive ? dumpPath(srcPath, filter).decay()
|
||||
: readFileSource(srcPath)
|
||||
};
|
||||
co_return addToStoreFromDump(source, name, method, hashAlgo, repair, references);
|
||||
co_return TRY_AWAIT(addToStoreFromDump(source, name, method, hashAlgo, repair, references));
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
@@ -554,10 +554,10 @@ public:
|
||||
*
|
||||
* \todo remove?
|
||||
*/
|
||||
virtual StorePath addToStoreFromDump(Source & dump, std::string_view name,
|
||||
virtual kj::Promise<Result<StorePath>> addToStoreFromDump(Source & dump, std::string_view name,
|
||||
FileIngestionMethod method = FileIngestionMethod::Recursive, HashType hashAlgo = HashType::SHA256, RepairFlag repair = NoRepair,
|
||||
const StorePathSet & references = StorePathSet())
|
||||
{ unsupported("addToStoreFromDump"); }
|
||||
try { unsupported("addToStoreFromDump"); } catch (...) { return {result::current_exception()}; }
|
||||
|
||||
/**
|
||||
* Like addToStore, but the contents written to the output path is a
|
||||
|
||||
Reference in New Issue
Block a user