From efcd30da891eccdb3518e9c07afc6f907e9ac5e6 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 2 Jun 2020 00:37:43 +0000 Subject: WIP --- src/libstore/store-api.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/libstore/store-api.cc') diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 0a36dcb2b..0715f64f3 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -468,7 +468,7 @@ void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & store } if (info->ca) - jsonPath.attr("ca", info->ca); + jsonPath.attr("ca", renderContentAddress(info->ca)); std::pair closureSizes; @@ -760,24 +760,23 @@ bool ValidPathInfo::isContentAddressed(const Store & store) const printError("warning: path '%s' claims to be content-addressed but isn't", store.printStorePath(path)); }; - if (hasPrefix(ca, "text:")) { - Hash hash(std::string(ca, 5)); - if (store.makeTextPath(path.name(), hash, references) == path) + if (! ca) {} + + else if (auto p = std::get_if(&*ca)) { + if (store.makeTextPath(path.name(), p->hash, references) == path) return true; else warn(); } - else if (hasPrefix(ca, "fixed:")) { - FileIngestionMethod recursive { ca.compare(6, 2, "r:") == 0 }; - Hash hash(std::string(ca, recursive == FileIngestionMethod::Recursive ? 8 : 6)); + else if (auto p = std::get_if(&*ca)) { auto refs = cloneStorePathSet(references); bool hasSelfReference = false; if (refs.count(path)) { hasSelfReference = true; refs.erase(path); } - if (store.makeFixedOutputPath(recursive, hash, path.name(), refs, hasSelfReference) == path) + if (store.makeFixedOutputPath(p->method, p->hash, path.name(), refs, hasSelfReference) == path) return true; else warn(); -- cgit v1.2.3