libstore: un-callback-ify Store::queryRealisationUncached

Change-Id: I4a328f46eaac3bb8b19ddc091306de83348be9cf
This commit is contained in:
eldritch horrors
2024-05-09 23:18:05 +02:00
parent 2f4a1dd6e0
commit 17965bf11c
11 changed files with 60 additions and 94 deletions
+6 -11
View File
@@ -442,21 +442,16 @@ StorePath BinaryCacheStore::addTextToStore(
})->path;
}
void BinaryCacheStore::queryRealisationUncached(const DrvOutput & id,
Callback<std::shared_ptr<const Realisation>> callback) noexcept
std::shared_ptr<const Realisation> BinaryCacheStore::queryRealisationUncached(const DrvOutput & id)
{
auto outputInfoFilePath = realisationsPrefix + "/" + id.to_string() + ".doi";
try {
auto data = getFile(outputInfoFilePath);
if (!data) return callback({});
auto data = getFile(outputInfoFilePath);
if (!data) return {};
auto realisation = Realisation::fromJSON(
nlohmann::json::parse(*data), outputInfoFilePath);
return callback(std::make_shared<const Realisation>(realisation));
} catch (...) {
callback.rethrow();
}
auto realisation = Realisation::fromJSON(
nlohmann::json::parse(*data), outputInfoFilePath);
return std::make_shared<const Realisation>(realisation);
}
void BinaryCacheStore::registerDrvOutput(const Realisation& info) {