about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/local-store.cc6
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.cc6
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/store-api.cc11
-rw-r--r--src/libstore/store-api.hh6
6 files changed, 17 insertions, 16 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index fc62a99930..bb53caacc5 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -656,7 +656,7 @@ void LocalStore::invalidatePath(const Path & path)
 
 
 Path LocalStore::addToStore(const Path & _srcPath,
-    bool recursive, string hashAlgo, PathFilter & filter)
+    bool recursive, HashType hashAlgo, PathFilter & filter)
 {
     Path srcPath(absPath(_srcPath));
     debug(format("adding `%1%' to the store") % srcPath);
@@ -670,7 +670,7 @@ Path LocalStore::addToStore(const Path & _srcPath,
     else
         sink.s = readFile(srcPath);
 
-    Hash h = hashString(parseHashType(hashAlgo), sink.s);
+    Hash h = hashString(hashAlgo, sink.s);
 
     Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, baseNameOf(srcPath));
 
@@ -700,7 +700,7 @@ Path LocalStore::addToStore(const Path & _srcPath,
                above (if called with recursive == true and hashAlgo ==
                sha256); otherwise, compute it here. */
             registerValidPath(dstPath,
-                (recursive && hashAlgo == "sha256") ? h :
+                (recursive && hashAlgo == htSHA256) ? h :
                 (recursive ? hashString(htSHA256, sink.s) : hashPath(htSHA256, dstPath)),
                 PathSet(), "");
         }
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 3d47446f6e..77e46fc3cc 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -90,7 +90,7 @@ public:
         const Path & path, SubstitutablePathInfo & info);
     
     Path addToStore(const Path & srcPath,
-        bool recursive = true, string hashAlgo = "sha256",
+        bool recursive = true, HashType hashAlgo = htSHA256,
         PathFilter & filter = defaultPathFilter);
 
     Path addTextToStore(const string & name, const string & s,
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index f79b22310b..d83d501ee2 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -279,16 +279,16 @@ Path RemoteStore::queryDeriver(const Path & path)
 
 
 Path RemoteStore::addToStore(const Path & _srcPath,
-    bool recursive, string hashAlgo, PathFilter & filter)
+    bool recursive, HashType hashAlgo, PathFilter & filter)
 {
     Path srcPath(absPath(_srcPath));
     
     writeInt(wopAddToStore, to);
     writeString(baseNameOf(srcPath), to);
     /* backwards compatibility hack */
-    writeInt((hashAlgo == "sha256" && recursive) ? 0 : 1, to);
+    writeInt((hashAlgo == htSHA256 && recursive) ? 0 : 1, to);
     writeInt(recursive ? 1 : 0, to);
-    writeString(hashAlgo, to);
+    writeString(printHashType(hashAlgo), to);
     dumpPath(srcPath, to, filter);
     processStderr();
     return readStorePath(from);
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index cb9124a4cd..717da73772 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -43,7 +43,7 @@ public:
         SubstitutablePathInfo & info);
     
     Path addToStore(const Path & srcPath,
-        bool recursive = true, string hashAlgo = "sha256",
+        bool recursive = true, HashType hashAlgo = htSHA256,
         PathFilter & filter = defaultPathFilter);
 
     Path addTextToStore(const string & name, const string & s,
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index fe4ecfad54..bd330a6da9 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -183,20 +183,21 @@ Path makeStorePath(const string & type,
 
 
 Path makeFixedOutputPath(bool recursive,
-    string hashAlgo, Hash hash, string name)
+    HashType hashAlgo, Hash hash, string name)
 {
-    return hashAlgo == "sha256" && recursive
+    return hashAlgo == htSHA256 && recursive
         ? makeStorePath("source", hash, name)
         : makeStorePath("output:out", hashString(htSHA256,
-                "fixed:out:" + (recursive ? (string) "r:" : "") + hashAlgo + ":" + printHash(hash) + ":"),
+                "fixed:out:" + (recursive ? (string) "r:" : "") +
+                printHashType(hashAlgo) + ":" + printHash(hash) + ":"),
             name);
 }
 
 
 std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
-    bool recursive, string hashAlgo, PathFilter & filter)
+    bool recursive, HashType hashAlgo, PathFilter & filter)
 {
-    HashType ht(parseHashType(hashAlgo));
+    HashType ht(hashAlgo);
     Hash h = recursive ? hashPath(ht, srcPath, filter) : hashFile(ht, srcPath);
     string name = baseNameOf(srcPath);
     Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index adfd40a919..1c6f737285 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -174,7 +174,7 @@ public:
        object `filter' can be used to exclude files (see
        libutil/archive.hh). */
     virtual Path addToStore(const Path & srcPath,
-        bool recursive = true, string hashAlgo = "sha256",
+        bool recursive = true, HashType hashAlgo = htSHA256,
         PathFilter & filter = defaultPathFilter) = 0;
 
     /* Like addToStore, but the contents written to the output path is
@@ -277,7 +277,7 @@ Path makeStorePath(const string & type,
     const Hash & hash, const string & name);
     
 Path makeFixedOutputPath(bool recursive,
-    string hashAlgo, Hash hash, string name);
+    HashType hashAlgo, Hash hash, string name);
 
 
 /* This is the preparatory part of addToStore() and addToStoreFixed();
@@ -285,7 +285,7 @@ Path makeFixedOutputPath(bool recursive,
    Returns the store path and the cryptographic hash of the
    contents of srcPath. */
 std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
-    bool recursive = true, string hashAlgo = "sha256",
+    bool recursive = true, HashType hashAlgo = htSHA256,
     PathFilter & filter = defaultPathFilter);
 
 /* Preparatory part of addTextToStore().