1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 06:22:42 +01:00

builtins.fetch{url,tarball}: Allow name attribute

(cherry picked from commit d52d391164)
This commit is contained in:
Shea Levy 2016-08-15 07:37:11 -04:00
parent 66151dc154
commit 7bb4d028a8
3 changed files with 12 additions and 8 deletions

View file

@ -188,7 +188,7 @@ DownloadResult downloadFile(string url, const DownloadOptions & options)
}
Path downloadFileCached(const string & url, bool unpack)
Path downloadFileCached(const string & url, bool unpack, string name)
{
Path cacheDir = getEnv("XDG_CACHE_HOME", getEnv("HOME", "") + "/.cache") + "/nix/tarballs";
createDirs(cacheDir);
@ -223,9 +223,10 @@ Path downloadFileCached(const string & url, bool unpack)
storePath = "";
}
string name;
auto p = url.rfind('/');
if (p != string::npos) name = string(url, p + 1);
if (name == "") {
auto p = url.rfind('/');
if (p != string::npos) name = string(url, p + 1);
}
if (!skip) {

View file

@ -20,7 +20,7 @@ struct DownloadResult
DownloadResult downloadFile(string url, const DownloadOptions & options);
Path downloadFileCached(const string & url, bool unpack);
Path downloadFileCached(const string & url, bool unpack, string name = "");
MakeError(DownloadError, Error)