diff options
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index c8097da52..661dea141 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -173,20 +173,20 @@ static std::string makeType( StorePath Store::makeFixedOutputPath( - FileIngestionMethod recursive, + FileIngestionMethod method, const Hash & hash, std::string_view name, const StorePathSet & references, bool hasSelfReference) const { - if (hash.type == htSHA256 && recursive == FileIngestionMethod::Recursive) { + if (hash.type == htSHA256 && method == FileIngestionMethod::Recursive) { return makeStorePath(makeType(*this, "source", references, hasSelfReference), hash, name); } else { assert(references.empty()); return makeStorePath("output:out", hashString(htSHA256, "fixed:out:" - + (recursive == FileIngestionMethod::Recursive ? (string) "r:" : "") + + makeFileIngestionPrefix(method) + hash.to_string(Base16, true) + ":"), name); } @@ -864,10 +864,21 @@ Strings ValidPathInfo::shortRefs() const } -std::string makeFixedOutputCA(FileIngestionMethod recursive, const Hash & hash) +std::string makeFileIngestionPrefix(const FileIngestionMethod m) { + switch (m) { + case FileIngestionMethod::Flat: + return ""; + case FileIngestionMethod::Recursive: + return "r:"; + default: + throw Error("impossible, caught both cases"); + } +} + +std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash) { return "fixed:" - + (recursive == FileIngestionMethod::Recursive ? (std::string) "r:" : "") + + makeFileIngestionPrefix(method) + hash.to_string(Base32, true); } |