about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/download.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
committerVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
commit838f86b0fd880b26539664140f04e5d16669dad8 (patch)
treec8fee2f0c136fbe5bb0735604e2f04d5b02698ba /third_party/nix/src/libstore/download.cc
parentf30b2e610d9e612504a9f6460e0cc83413b80aeb (diff)
style(3p/nix): Remove 'using std::*' from types.hh r/840
It is considered bad form to use things from includes in headers, as
these directives propagate to everywhere else and can make it
confusing.

types.hh (which is includes almost literally everywhere) had some of
these directives, which this commit removes.
Diffstat (limited to 'third_party/nix/src/libstore/download.cc')
-rw-r--r--third_party/nix/src/libstore/download.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc
index 876734478785..c96caf474c0d 100644
--- a/third_party/nix/src/libstore/download.cc
+++ b/third_party/nix/src/libstore/download.cc
@@ -177,7 +177,7 @@ struct CurlDownloader : public Downloader {
       DLOG(INFO) << "got header for '" << request.uri << "': " << trim(line);
       if (line.compare(0, 5, "HTTP/") == 0) {  // new response starts
         result.etag = "";
-        auto ss = tokenizeString<vector<string>>(line, " ");
+        auto ss = tokenizeString<std::vector<std::string>>(line, " ");
         status = ss.size() >= 2 ? ss[1] : "";
         result.data = std::make_shared<std::string>();
         result.bodySize = 0;
@@ -185,10 +185,10 @@ struct CurlDownloader : public Downloader {
         encoding = "";
       } else {
         auto i = line.find(':');
-        if (i != string::npos) {
-          string name = toLower(trim(string(line, 0, i)));
+        if (i != std::string::npos) {
+          std::string name = toLower(trim(std::string(line, 0, i)));
           if (name == "etag") {
-            result.etag = trim(string(line, i + 1));
+            result.etag = trim(std::string(line, i + 1));
             /* Hack to work around a GitHub bug: it sends
                ETags, but ignores If-None-Match. So if we get
                the expected ETag on a 200 response, then shut
@@ -200,7 +200,7 @@ struct CurlDownloader : public Downloader {
               return 0;
             }
           } else if (name == "content-encoding") {
-            encoding = trim(string(line, i + 1));
+            encoding = trim(std::string(line, i + 1));
           } else if (name == "accept-ranges" &&
                      toLower(trim(std::string(line, i + 1))) == "bytes") {
             acceptRanges = true;
@@ -868,8 +868,8 @@ CachedDownloadResult Downloader::downloadCached(
   auto name = request.name;
   if (name.empty()) {
     auto p = url.rfind('/');
-    if (p != string::npos) {
-      name = string(url, p + 1);
+    if (p != std::string::npos) {
+      name = std::string(url, p + 1);
     }
   }
 
@@ -888,8 +888,8 @@ CachedDownloadResult Downloader::downloadCached(
   Path cacheDir = getCacheDir() + "/nix/tarballs";
   createDirs(cacheDir);
 
-  string urlHash = hashString(htSHA256, name + std::string("\0"s) + url)
-                       .to_string(Base32, false);
+  std::string urlHash = hashString(htSHA256, name + std::string("\0"s) + url)
+                            .to_string(Base32, false);
 
   Path dataFile = cacheDir + "/" + urlHash + ".info";
   Path fileLink = cacheDir + "/" + urlHash + "-file";
@@ -898,7 +898,7 @@ CachedDownloadResult Downloader::downloadCached(
 
   Path storePath;
 
-  string expectedETag;
+  std::string expectedETag;
 
   bool skip = false;
 
@@ -908,7 +908,8 @@ CachedDownloadResult Downloader::downloadCached(
     storePath = readLink(fileLink);
     store->addTempRoot(storePath);
     if (store->isValidPath(storePath)) {
-      auto ss = tokenizeString<vector<string>>(readFile(dataFile), "\n");
+      auto ss =
+          tokenizeString<std::vector<std::string>>(readFile(dataFile), "\n");
       if (ss.size() >= 3 && ss[0] == url) {
         time_t lastChecked;
         if (string2Int(ss[2], lastChecked) &&
@@ -1009,15 +1010,15 @@ CachedDownloadResult Downloader::downloadCached(
   return result;
 }
 
-bool isUri(const string& s) {
+bool isUri(const std::string& s) {
   if (s.compare(0, 8, "channel:") == 0) {
     return true;
   }
   size_t pos = s.find("://");
-  if (pos == string::npos) {
+  if (pos == std::string::npos) {
     return false;
   }
-  string scheme(s, 0, pos);
+  std::string scheme(s, 0, pos);
   return scheme == "http" || scheme == "https" || scheme == "file" ||
          scheme == "channel" || scheme == "git" || scheme == "s3" ||
          scheme == "ssh";