From d52d391164d9a6fb4a2efec2777e24de5e19b225 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Mon, 15 Aug 2016 07:37:11 -0400 Subject: builtins.fetch{url,tarball}: Allow name attribute --- src/libstore/download.cc | 9 +++++---- src/libstore/download.hh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/libstore') diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 95c7d2255a..13c665a40c 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -243,13 +243,14 @@ ref makeDownloader() return make_ref(); } -Path Downloader::downloadCached(ref store, const string & url_, bool unpack, const Hash & expectedHash) +Path Downloader::downloadCached(ref 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 1f6098759a..08618ba1c9 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, const string & url, bool unpack, + Path downloadCached(ref store, const string & url, bool unpack, string name = "", const Hash & expectedHash = Hash()); enum Error { NotFound, Forbidden, Misc, Transient }; -- cgit 1.4.1