diff options
author | Shea Levy <shea@shealevy.com> | 2016-08-15T11·37-0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2016-08-15T11·37-0400 |
commit | d52d391164d9a6fb4a2efec2777e24de5e19b225 (patch) | |
tree | 4e1ab818d97a2054abd612b3358b7bb1c18f7102 /src/libstore | |
parent | eff80419c76eb7d77d3b434a45fb9e18d53d1d19 (diff) |
builtins.fetch{url,tarball}: Allow name attribute
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/download.cc | 9 | ||||
-rw-r--r-- | src/libstore/download.hh | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 95c7d2255afc..13c665a40ca8 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -243,13 +243,14 @@ ref<Downloader> makeDownloader() return make_ref<CurlDownloader>(); } -Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpack, const Hash & expectedHash) +Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpack, string name, const Hash & expectedHash) { auto url = resolveUri(url_); - 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); + } Path expectedStorePath; if (expectedHash) { diff --git a/src/libstore/download.hh b/src/libstore/download.hh index 1f6098759a2d..08618ba1c95d 100644 --- a/src/libstore/download.hh +++ b/src/libstore/download.hh @@ -29,7 +29,7 @@ struct Downloader { virtual DownloadResult download(string url, const DownloadOptions & options) = 0; - Path downloadCached(ref<Store> store, const string & url, bool unpack, + Path downloadCached(ref<Store> store, const string & url, bool unpack, string name = "", const Hash & expectedHash = Hash()); enum Error { NotFound, Forbidden, Misc, Transient }; |