about summary refs log tree commit diff
path: root/src/libstore/download.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-06-01T12·14+0200
committerEelco Dolstra <edolstra@gmail.com>2018-06-01T12·14+0200
commit73357500aca2ad4a2d82111993fbd5aaf0af4ec6 (patch)
tree1a29541c85aa2ed7f8997b8a99348145b73972b7 /src/libstore/download.cc
parentf0d9909f108b2f8bffaf65743e283e773204b62f (diff)
Improve binary cache upload messages
Don't say "download" when we mean "upload".
Diffstat (limited to 'src/libstore/download.cc')
-rw-r--r--src/libstore/download.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 72a08ef008..0b768b5917 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -102,7 +102,9 @@ struct CurlDownloader : public Downloader
             Callback<DownloadResult> callback)
             : downloader(downloader)
             , request(request)
-            , act(*logger, lvlTalkative, actDownload, fmt("downloading '%s'", request.uri), {request.uri}, request.parentAct)
+            , act(*logger, lvlTalkative, actDownload,
+                fmt(request.data ? "uploading '%s'" : "downloading '%s'", request.uri),
+                {request.uri}, request.parentAct)
             , callback(callback)
         {
             if (!request.expectedETag.empty())
@@ -371,12 +373,20 @@ struct CurlDownloader : public Downloader
 
                 attempt++;
 
+                auto verb = request.data ? "upload" : "download";
+
                 auto exc =
                     code == CURLE_ABORTED_BY_CALLBACK && _isInterrupted
-                    ? DownloadError(Interrupted, format("download of '%s' was interrupted") % request.uri)
+                    ? DownloadError(Interrupted, fmt("%s of '%s' was interrupted", verb, request.uri))
                     : httpStatus != 0
-                      ? DownloadError(err, format("unable to download '%s': HTTP error %d (curl error: %s)") % request.uri % httpStatus % curl_easy_strerror(code))
-                      : DownloadError(err, format("unable to download '%s': %s (%d)") % request.uri % curl_easy_strerror(code) % code);
+                    ? DownloadError(err,
+                        fmt("unable to %s '%s': HTTP error %d",
+                            verb, request.uri, httpStatus)
+                        + (code == CURLE_OK ? "" : fmt(" (curl error: %s)", curl_easy_strerror(code)))
+                        )
+                    : DownloadError(err,
+                        fmt("unable to %s '%s': %s (%d)",
+                            verb, request.uri, curl_easy_strerror(code), code));
 
                 /* If this is a transient error, then maybe retry the
                    download after a while. */