mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Convert Realisation JSON logic to standard style
No behavior is changed, just: - Declare a canonical `nlohmnan::json::adl_serializer` - Use `json-utils.hh` to shorten code without getting worse error messages. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
6389f65d63
commit
91593a237f
7 changed files with 73 additions and 61 deletions
|
|
@ -515,8 +515,14 @@ void BinaryCacheStore::queryRealisationUncached(
|
|||
if (!data)
|
||||
return (*callbackPtr)({});
|
||||
|
||||
auto realisation = Realisation::fromJSON(nlohmann::json::parse(*data), outputInfoFilePath);
|
||||
return (*callbackPtr)(std::make_shared<const Realisation>(realisation));
|
||||
std::shared_ptr<const Realisation> realisation;
|
||||
try {
|
||||
realisation = std::make_shared<const Realisation>(nlohmann::json::parse(*data));
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while parsing file '%s' as a realisation", outputInfoFilePath);
|
||||
throw;
|
||||
}
|
||||
return (*callbackPtr)(std::move(realisation));
|
||||
} catch (...) {
|
||||
callbackPtr->rethrow();
|
||||
}
|
||||
|
|
@ -530,7 +536,7 @@ void BinaryCacheStore::registerDrvOutput(const Realisation & info)
|
|||
if (diskCache)
|
||||
diskCache->upsertRealisation(config.getReference().render(/*FIXME withParams=*/false), info);
|
||||
auto filePath = realisationsPrefix + "/" + info.id.to_string() + ".doi";
|
||||
upsertFile(filePath, info.toJSON().dump(), "application/json");
|
||||
upsertFile(filePath, static_cast<nlohmann::json>(info).dump(), "application/json");
|
||||
}
|
||||
|
||||
ref<SourceAccessor> BinaryCacheStore::getFSAccessor(bool requireValidPath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue