about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/binary-cache-store.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T17·55+0100
commit867055133d3f487e52dd44149f76347c2c28bf10 (patch)
treec367803ad94f024b0052727a2c7a037af169169a /third_party/nix/src/libstore/binary-cache-store.cc
parentc6a31838cd7e88ebcb01422b329a499d04ab4b6b (diff)
style(3p/nix): Add braces around single-line conditionals r/771
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

    ambr --regex 'if (\(.+\))\s([a-z].*;)' 'if $1 { $2 }'

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libstore/binary-cache-store.cc')
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/third_party/nix/src/libstore/binary-cache-store.cc b/third_party/nix/src/libstore/binary-cache-store.cc
index a1bcd3c0cf80..625ea1e11eae 100644
--- a/third_party/nix/src/libstore/binary-cache-store.cc
+++ b/third_party/nix/src/libstore/binary-cache-store.cc
@@ -38,7 +38,9 @@ void BinaryCacheStore::init() {
   } else {
     for (auto& line : tokenizeString<Strings>(*cacheInfo, "\n")) {
       size_t colon = line.find(':');
-      if (colon == std::string::npos) continue;
+      if (colon == std::string::npos) {
+        continue;
+      }
       auto name = line.substr(0, colon);
       auto value = trim(line.substr(colon + 1, std::string::npos));
       if (name == "StoreDir") {
@@ -115,12 +117,16 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
                                   const ref<std::string>& nar,
                                   RepairFlag repair, CheckSigsFlag checkSigs,
                                   std::shared_ptr<FSAccessor> accessor) {
-  if (!repair && isValidPath(info.path)) return;
+  if (!repair && isValidPath(info.path)) {
+    return;
+  }
 
   /* Verify that all references are valid. This may do some .narinfo
      reads, but typically they'll already be cached. */
   for (auto& ref : info.references) try {
-      if (ref != info.path) queryPathInfo(ref);
+      if (ref != info.path) {
+        queryPathInfo(ref);
+      }
     } catch (InvalidPath&) {
       throw Error(format("cannot add '%s' to the binary cache because the "
                          "reference '%s' is not valid") %
@@ -152,7 +158,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
 
       auto narAccessor = makeNarAccessor(nar);
 
-      if (accessor_) accessor_->addToCache(info.path, *nar, narAccessor);
+      if (accessor_) {
+        accessor_->addToCache(info.path, *nar, narAccessor);
+      }
 
       {
         auto res = jsonRoot.placeholder("root");
@@ -165,7 +173,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
   }
 
   else {
-    if (accessor_) accessor_->addToCache(info.path, *nar, makeNarAccessor(nar));
+    if (accessor_) {
+      accessor_->addToCache(info.path, *nar, makeNarAccessor(nar));
+    }
   }
 
   /* Compress the NAR. */
@@ -201,7 +211,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
   stats.narWriteCompressionTimeMs += duration;
 
   /* Atomically write the NAR info file.*/
-  if (secretKey) narInfo->sign(*secretKey);
+  if (secretKey) {
+    narInfo->sign(*secretKey);
+  }
 
   writeNarInfo(narInfo);
 
@@ -254,7 +266,9 @@ void BinaryCacheStore::queryPathInfoUncached(
             try {
               auto data = fut.get();
 
-              if (!data) return (*callbackPtr)(nullptr);
+              if (!data) {
+                return (*callbackPtr)(nullptr);
+              }
 
               stats.narInfoRead++;
 
@@ -341,7 +355,9 @@ std::shared_ptr<std::string> BinaryCacheStore::getBuildLog(const Path& path) {
     try {
       auto info = queryPathInfo(path);
       // FIXME: add a "Log" field to .narinfo
-      if (info->deriver == "") return nullptr;
+      if (info->deriver == "") {
+        return nullptr;
+      }
       drvPath = info->deriver;
     } catch (InvalidPath&) {
       return nullptr;