about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-21T13·03+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-21T13·14+0200
commit01615b5f63ad26307a7e47a9b6508e5e779a1e83 (patch)
treeee76a7419a9e6c829ed3260947cfdc218c481034 /src/libstore
parent5db358d4d78aea7204a8f22c5bf2a309267ee038 (diff)
Show progress indicator for builtin fetchurl
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/builtins.cc6
-rw-r--r--src/libstore/download.cc4
-rw-r--r--src/libstore/download.hh1
3 files changed, 7 insertions, 4 deletions
diff --git a/src/libstore/builtins.cc b/src/libstore/builtins.cc
index 091a67428e..2a43963083 100644
--- a/src/libstore/builtins.cc
+++ b/src/libstore/builtins.cc
@@ -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");
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 8ef3ab3f0b..94c13249d4 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -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)
diff --git a/src/libstore/download.hh b/src/libstore/download.hh
index aff109ee7c..c1cb25b90c 100644
--- a/src/libstore/download.hh
+++ b/src/libstore/download.hh
@@ -9,6 +9,7 @@ struct DownloadOptions
 {
     string expectedETag;
     bool verifyTLS{true};
+    bool forceProgress{false};
 };
 
 struct DownloadResult