Show progress indicator for builtin fetchurl
This commit is contained in:
parent
5db358d4d7
commit
01615b5f63
3 changed files with 7 additions and 4 deletions
|
@ -7,14 +7,16 @@ void builtinFetchurl(const BasicDerivation & drv)
|
|||
{
|
||||
auto url = drv.env.find("url");
|
||||
if (url == drv.env.end()) throw Error("attribute ‘url’ missing");
|
||||
printMsg(lvlInfo, format("downloading ‘%1%’...") % url->second);
|
||||
|
||||
/* No need to do TLS verification, because we check the hash of
|
||||
the result anyway. */
|
||||
DownloadOptions options;
|
||||
options.verifyTLS = false;
|
||||
|
||||
auto data = downloadFile(url->second, options); // FIXME: show progress
|
||||
/* Show a progress indicator, even though stderr is not a tty. */
|
||||
options.forceProgress = true;
|
||||
|
||||
auto data = downloadFile(url->second, options);
|
||||
|
||||
auto out = drv.env.find("out");
|
||||
if (out == drv.env.end()) throw Error("attribute ‘url’ missing");
|
||||
|
|
|
@ -114,8 +114,6 @@ struct Curl
|
|||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback_);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *) &curl);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
|
||||
showProgress = isatty(STDERR_FILENO);
|
||||
}
|
||||
|
||||
~Curl()
|
||||
|
@ -126,6 +124,8 @@ struct Curl
|
|||
|
||||
bool fetch(const string & url, const DownloadOptions & options)
|
||||
{
|
||||
showProgress = options.forceProgress || isatty(STDERR_FILENO);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
|
||||
if (options.verifyTLS)
|
||||
|
|
|
@ -9,6 +9,7 @@ struct DownloadOptions
|
|||
{
|
||||
string expectedETag;
|
||||
bool verifyTLS{true};
|
||||
bool forceProgress{false};
|
||||
};
|
||||
|
||||
struct DownloadResult
|
||||
|
|
Loading…
Reference in a new issue