diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-02 00:37:43 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-02 00:37:43 +0000 |
commit | efcd30da891eccdb3518e9c07afc6f907e9ac5e6 (patch) | |
tree | 70b91a28476765350a9102a245d6a83da82af26f /src/libstore/store-api.cc | |
parent | 754c910953901ced4fbd27a8b86d36d57cb72996 (diff) |
WIP
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 15 |
1 files changed, 7 insertions, 8 deletions
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<uint64_t, uint64_t> 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<TextHash>(&*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<FileSystemHash>(&*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(); |