diff options
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 108e2d4ce9b0..0440af95fa42 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -455,49 +455,55 @@ string Store::makeValidityRegistration(const PathSet & paths, void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const PathSet & storePaths, - bool includeImpureInfo, bool showClosureSize) + bool includeImpureInfo, bool showClosureSize, AllowInvalidFlag allowInvalid) { auto jsonList = jsonOut.list(); for (auto storePath : storePaths) { - auto info = queryPathInfo(storePath); - storePath = info->path; - auto jsonPath = jsonList.object(); - jsonPath - .attr("path", storePath) - .attr("narHash", info->narHash.to_string()) - .attr("narSize", info->narSize); + jsonPath.attr("path", storePath); - { - auto jsonRefs = jsonPath.list("references"); - for (auto & ref : info->references) - jsonRefs.elem(ref); - } + try { + auto info = queryPathInfo(storePath); + storePath = info->path; - if (info->ca != "") - jsonPath.attr("ca", info->ca); + jsonPath + .attr("narHash", info->narHash.to_string()) + .attr("narSize", info->narSize); - if (showClosureSize) - jsonPath.attr("closureSize", getClosureSize(storePath)); + { + auto jsonRefs = jsonPath.list("references"); + for (auto & ref : info->references) + jsonRefs.elem(ref); + } - if (includeImpureInfo) { + if (info->ca != "") + jsonPath.attr("ca", info->ca); - if (info->deriver != "") - jsonPath.attr("deriver", info->deriver); + if (showClosureSize) + jsonPath.attr("closureSize", getClosureSize(storePath)); - if (info->registrationTime) - jsonPath.attr("registrationTime", info->registrationTime); + if (includeImpureInfo) { - if (info->ultimate) - jsonPath.attr("ultimate", info->ultimate); + if (info->deriver != "") + jsonPath.attr("deriver", info->deriver); + + if (info->registrationTime) + jsonPath.attr("registrationTime", info->registrationTime); + + if (info->ultimate) + jsonPath.attr("ultimate", info->ultimate); + + if (!info->sigs.empty()) { + auto jsonSigs = jsonPath.list("signatures"); + for (auto & sig : info->sigs) + jsonSigs.elem(sig); + } - if (!info->sigs.empty()) { - auto jsonSigs = jsonPath.list("signatures"); - for (auto & sig : info->sigs) - jsonSigs.elem(sig); } + } catch (InvalidPath &) { + jsonPath.attr("valid", false); } } } |