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/references.cc8
-rw-r--r--src/libstore/store.cc12
2 files changed, 11 insertions, 9 deletions
diff --git a/src/libstore/references.cc b/src/libstore/references.cc
index 9b20b980a1b2..5ceae6427617 100644
--- a/src/libstore/references.cc
+++ b/src/libstore/references.cc
@@ -81,8 +81,12 @@ Strings filterReferences(const string & path, const Strings & paths)
     for (Strings::const_iterator i = paths.begin();
          i != paths.end(); i++)
     {
-        string s = string(baseNameOf(*i), 0, 32);
-        parseHash(s);
+        string baseName = baseNameOf(*i);
+        unsigned int pos = baseName.find('-');
+        if (pos == string::npos)
+            throw Error(format("bad reference `%1%'") % *i);
+        string s = string(baseName, 0, pos);
+        // parseHash(htSHA256, s);
         ids.push_back(s);
         backMap[s] = *i;
     }
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 3a76618a5a39..e490bf258195 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -415,14 +415,12 @@ Path makeStorePath(const string & type,
     Hash & hash, const string & suffix)
 {
     /* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
-    string s = type + ":sha256:" + (string) hash + ":"
+    string s = type + ":sha256:" + printHash(hash) + ":"
         + nixStore + ":" + suffix;
 
-    Hash nameHash = hashString(s, htSHA256);
-
-    printMsg(lvlError, format("name input: %1% -> %2%") % s % (string) nameHash);
-
-    return nixStore + "/" + (string) nameHash + "-" + suffix;
+    return nixStore + "/"
+        + printHash32(compressHash(hashString(s, htSHA256), 20))
+        + "-" + suffix;
 }
 
 
@@ -461,7 +459,7 @@ Path addToStore(const Path & _srcPath)
             Hash h2 = hashPath(dstPath, htSHA256);
             if (h != h2)
                 throw Error(format("contents of `%1%' changed while copying it to `%2%' (%3% -> %4%)")
-                    % srcPath % dstPath % (string) h % (string) h2);
+                    % srcPath % dstPath % printHash(h) % printHash(h2));
 
             makePathReadOnly(dstPath);