about summary refs log tree commit diff
path: root/src/libstore/download.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-10-30T09·16+0100
committerEelco Dolstra <edolstra@gmail.com>2017-10-30T09·22+0100
commit66ddbef7547a2b5430c6d87e2d8d52977f7bf6f0 (patch)
treedd47c67718b9de379ae30fc39ba45d354035d8e4 /src/libstore/download.cc
parentf25791c196e7bcf76aa76e143a679fe731f77513 (diff)
fetchurl/fetchTarball: Respect name changes
The computation of urlHash didn't take the name into account, so
subsequent fetchurl calls with the same URL but a different name would
resolve to the same cached store path.
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r--src/libstore/download.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 608b8fd399b4..579a5e8c1b59 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -23,6 +23,8 @@
 #include <cmath>
 #include <random>
 
+using namespace std::string_literals;
+
 namespace nix {
 
 double getTime()
@@ -604,7 +606,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
     Path cacheDir = getCacheDir() + "/nix/tarballs";
     createDirs(cacheDir);
 
-    string urlHash = hashString(htSHA256, url).to_string(Base32, false);
+    string urlHash = hashString(htSHA256, name + std::string("\0"s) + url).to_string(Base32, false);
 
     Path dataFile = cacheDir + "/" + urlHash + ".info";
     Path fileLink = cacheDir + "/" + urlHash + "-file";