aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-19 17:52:01 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-19 17:53:34 +0000
commit68294746aeb1d23d2859e5ccc1a0c971cd7d5120 (patch)
treec63ca1c6b5d879a60b985bfa04f03b065d407594 /src/libstore/store-api.cc
parentc98081d2702b535e6fe802e8dafbe65c329f9a3f (diff)
parent424bb5819f736af7413c343d462663474222eaac (diff)
Merge remote-tracking branch 'upstream/master' into no-hash-type-unknown
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 2615a43d4..982fc22b6 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);
}
@@ -822,10 +822,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);
}