about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-07-26T19·25+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-07-26T19·25+0200
commitee22a91ab847f63a22466f3bf63e33ca29da9cfe (patch)
tree6808d04aeb5b66411014f252c1ee3c1f1e35d0d9 /src/libstore
parent06bbfb6004942bfcddd930e746ee7a2bfe5c3872 (diff)
makeFixedOutputPath(): Drop superfluous HashType argument
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/binary-cache-store.cc2
-rw-r--r--src/libstore/build.cc10
-rw-r--r--src/libstore/derivations.cc4
-rw-r--r--src/libstore/derivations.hh2
-rw-r--r--src/libstore/download.cc4
-rw-r--r--src/libstore/local-store.cc8
-rw-r--r--src/libstore/store-api.cc11
-rw-r--r--src/libstore/store-api.hh2
8 files changed, 21 insertions, 22 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index 668f1e566c01..801ecd368a6b 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -209,7 +209,7 @@ Path BinaryCacheStore::addToStore(const string & name, const Path & srcPath,
     }
 
     ValidPathInfo info;
-    info.path = makeFixedOutputPath(recursive, hashAlgo, h, name);
+    info.path = makeFixedOutputPath(recursive, h, name);
 
     addToStore(info, *sink.s, repair);
 
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index af2c908c30db..10ae574f9e49 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2706,8 +2706,8 @@ void DerivationGoal::registerOutputs()
            hash). */
         if (i.second.hash != "") {
 
-            bool recursive; HashType ht; Hash h;
-            i.second.parseHashInfo(recursive, ht, h);
+            bool recursive; Hash h;
+            i.second.parseHashInfo(recursive, h);
 
             if (!recursive) {
                 /* The output path should be a regular file without
@@ -2719,11 +2719,11 @@ void DerivationGoal::registerOutputs()
 
             /* Check the hash. In hash mode, move the path produced by
                the derivation to its content-addressed location. */
-            Hash h2 = recursive ? hashPath(ht, actualPath).first : hashFile(ht, actualPath);
+            Hash h2 = recursive ? hashPath(h.type, actualPath).first : hashFile(h.type, actualPath);
             if (buildMode == bmHash) {
-                Path dest = worker.store.makeFixedOutputPath(recursive, ht, h2, drv->env["name"]);
+                Path dest = worker.store.makeFixedOutputPath(recursive, h2, drv->env["name"]);
                 printMsg(lvlError, format("build produced path ‘%1%’ with %2% hash ‘%3%’")
-                    % dest % printHashType(ht) % printHash16or32(h2));
+                    % dest % printHashType(h.type) % printHash16or32(h2));
                 if (worker.store.isValidPath(dest))
                     return;
                 Path actualDest = worker.store.toRealPath(dest);
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 5590b99b36fa..7dcf71d468df 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -9,7 +9,7 @@
 namespace nix {
 
 
-void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const
+void DerivationOutput::parseHashInfo(bool & recursive, Hash & hash) const
 {
     recursive = false;
     string algo = hashAlgo;
@@ -19,7 +19,7 @@ void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash
         algo = string(algo, 2);
     }
 
-    hashType = parseHashType(algo);
+    HashType hashType = parseHashType(algo);
     if (hashType == htUnknown)
         throw Error(format("unknown hash algorithm ‘%1%’") % algo);
 
diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh
index e27c937132e8..974de78c58d5 100644
--- a/src/libstore/derivations.hh
+++ b/src/libstore/derivations.hh
@@ -29,7 +29,7 @@ struct DerivationOutput
         this->hashAlgo = hashAlgo;
         this->hash = hash;
     }
-    void parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const;
+    void parseHashInfo(bool & recursive, Hash & hash) const;
 };
 
 typedef std::map<string, DerivationOutput> DerivationOutputs;
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index f099268953ab..cf3929cadd65 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -232,7 +232,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
 
     Path expectedStorePath;
     if (expectedHash) {
-        expectedStorePath = store->makeFixedOutputPath(unpack, expectedHash.type, expectedHash, name);
+        expectedStorePath = store->makeFixedOutputPath(unpack, expectedHash, name);
         if (store->isValidPath(expectedStorePath))
             return expectedStorePath;
     }
@@ -282,7 +282,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
                 StringSink sink;
                 dumpString(*res.data, sink);
                 Hash hash = hashString(expectedHash ? expectedHash.type : htSHA256, *res.data);
-                info.path = store->makeFixedOutputPath(false, hash.type, hash, name);
+                info.path = store->makeFixedOutputPath(false, hash, name);
                 info.narHash = hashString(htSHA256, *sink.s);
                 store->addToStore(info, *sink.s, false, true);
                 storePath = info.path;
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 822d5fce3fb3..96ce6a0d893b 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -486,9 +486,9 @@ void LocalStore::checkDerivationOutputs(const Path & drvPath, const Derivation &
         if (out == drv.outputs.end())
             throw Error(format("derivation ‘%1%’ does not have an output named ‘out’") % drvPath);
 
-        bool recursive; HashType ht; Hash h;
-        out->second.parseHashInfo(recursive, ht, h);
-        Path outPath = makeFixedOutputPath(recursive, ht, h, drvName);
+        bool recursive; Hash h;
+        out->second.parseHashInfo(recursive, h);
+        Path outPath = makeFixedOutputPath(recursive, h, drvName);
 
         StringPairs::const_iterator j = drv.env.find("out");
         if (out->second.path != outPath || j == drv.env.end() || j->second != outPath)
@@ -940,7 +940,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
 {
     Hash h = hashString(hashAlgo, dump);
 
-    Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
+    Path dstPath = makeFixedOutputPath(recursive, h, name);
 
     addTempRoot(dstPath);
 
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 2a062b9b2cd3..af002dcc8c33 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -191,13 +191,13 @@ Path Store::makeOutputPath(const string & id,
 
 
 Path Store::makeFixedOutputPath(bool recursive,
-    HashType hashAlgo, Hash hash, string name) const
+    const Hash & hash, const string & name) const
 {
-    return hashAlgo == htSHA256 && recursive
+    return hash.type == htSHA256 && recursive
         ? makeStorePath("source", hash, name)
         : makeStorePath("output:out", hashString(htSHA256,
                 "fixed:out:" + (recursive ? (string) "r:" : "") +
-                printHashType(hashAlgo) + ":" + printHash(hash) + ":"),
+                printHashType(hash.type) + ":" + printHash(hash) + ":"),
             name);
 }
 
@@ -205,10 +205,9 @@ Path Store::makeFixedOutputPath(bool recursive,
 std::pair<Path, Hash> Store::computeStorePathForPath(const Path & srcPath,
     bool recursive, HashType hashAlgo, PathFilter & filter) const
 {
-    HashType ht(hashAlgo);
-    Hash h = recursive ? hashPath(ht, srcPath, filter).first : hashFile(ht, srcPath);
+    Hash h = recursive ? hashPath(hashAlgo, srcPath, filter).first : hashFile(hashAlgo, srcPath);
     string name = baseNameOf(srcPath);
-    Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
+    Path dstPath = makeFixedOutputPath(recursive, h, name);
     return std::pair<Path, Hash>(dstPath, h);
 }
 
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 75caab7ea388..0b80312d6307 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -232,7 +232,7 @@ public:
         const Hash & hash, const string & name) const;
 
     Path makeFixedOutputPath(bool recursive,
-        HashType hashAlgo, Hash hash, string name) const;
+        const Hash & hash, const string & name) const;
 
     /* This is the preparatory part of addToStore() and
        addToStoreFixed(); it computes the store path to which srcPath