libstore: asyncify BinaryCacheStore::writeNarInfo

Change-Id: Iad36b9541876a6a66030db357104ed189b45c4f0
This commit is contained in:
eldritch horrors
2025-03-05 18:49:45 +01:00
parent a29e3a4a58
commit d3e435b2b9
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -86,8 +86,8 @@ std::string BinaryCacheStore::narInfoFileFor(const StorePath & storePath)
return std::string(storePath.hashPart()) + ".narinfo";
}
void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
{
kj::Promise<Result<void>> BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
try {
auto narInfoFile = narInfoFileFor(narInfo->path);
upsertFile(narInfoFile, narInfo->to_string(*this), "text/x-nix-narinfo");
@@ -101,6 +101,9 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo)
if (diskCache)
diskCache->upsertNarInfo(getUri(), std::string(narInfo->path.hashPart()), std::shared_ptr<NarInfo>(narInfo));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
kj::Promise<Result<ref<const ValidPathInfo>>> BinaryCacheStore::addToStoreCommon(
@@ -258,7 +261,7 @@ try {
/* Atomically write the NAR info file.*/
if (secretKey) narInfo->sign(*this, *secretKey);
writeNarInfo(narInfo);
TRY_AWAIT(writeNarInfo(narInfo));
stats.narInfoWrite++;
@@ -537,7 +540,7 @@ try {
narInfo->sigs.insert(sigs.begin(), sigs.end());
writeNarInfo(narInfo);
TRY_AWAIT(writeNarInfo(narInfo));
co_return result::success();
} catch (...) {
co_return result::current_exception();
+1 -1
View File
@@ -101,7 +101,7 @@ private:
std::string narInfoFileFor(const StorePath & storePath);
void writeNarInfo(ref<NarInfo> narInfo);
kj::Promise<Result<void>> writeNarInfo(ref<NarInfo> narInfo);
kj::Promise<Result<ref<const ValidPathInfo>>> addToStoreCommon(
AsyncInputStream & narSource, RepairFlag repair, CheckSigsFlag checkSigs,