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-19T19·47+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T19·51+0100
commit39087321811e81e26a1a47d6967df1088dcf0e95 (patch)
tree57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/libstore/binary-cache-store.cc
parentcf40d08908ede4061eb15513b770c98877844b8b (diff)
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including
compilation):

    clang-tidy -p ~/projects/nix-build/ \
      -checks=-*,readability-braces-around-statements -fix src/*/*.cc

Actually running clang-tidy requires some massaging to make it play
nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/libstore/binary-cache-store.cc')
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.cc23
1 files changed, 15 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 625ea1e11eae..10a0ddfc1363 100644
--- a/third_party/nix/src/libstore/binary-cache-store.cc
+++ b/third_party/nix/src/libstore/binary-cache-store.cc
@@ -19,9 +19,10 @@
 namespace nix {
 
 BinaryCacheStore::BinaryCacheStore(const Params& params) : Store(params) {
-  if (secretKeyFile != "")
+  if (secretKeyFile != "") {
     secretKey =
         std::unique_ptr<SecretKey>(new SecretKey(readFile(secretKeyFile)));
+  }
 
   StringSink sink;
   sink << narVersionMagic1;
@@ -44,10 +45,11 @@ void BinaryCacheStore::init() {
       auto name = line.substr(0, colon);
       auto value = trim(line.substr(colon + 1, std::string::npos));
       if (name == "StoreDir") {
-        if (value != storeDir)
+        if (value != storeDir) {
           throw Error(format("binary cache '%s' is for Nix stores with prefix "
                              "'%s', not '%s'") %
                       getUri() % value % storeDir);
+        }
       } else if (name == "WantMassQuery") {
         wantMassQuery_ = value == "1";
       } else if (name == "Priority") {
@@ -108,9 +110,10 @@ void BinaryCacheStore::writeNarInfo(ref<NarInfo> narInfo) {
     state_->pathInfoCache.upsert(hashPart, std::shared_ptr<NarInfo>(narInfo));
   }
 
-  if (diskCache)
+  if (diskCache) {
     diskCache->upsertNarInfo(getUri(), hashPart,
                              std::shared_ptr<NarInfo>(narInfo));
+  }
 }
 
 void BinaryCacheStore::addToStore(const ValidPathInfo& info,
@@ -123,7 +126,8 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
 
   /* 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 {
+  for (auto& ref : info.references) {
+    try {
       if (ref != info.path) {
         queryPathInfo(ref);
       }
@@ -132,6 +136,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
                          "reference '%s' is not valid") %
                   info.path % ref);
     }
+  }
 
   assert(nar->compare(0, narMagic.size(), narMagic) == 0);
 
@@ -140,10 +145,11 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
   narInfo->narSize = nar->size();
   narInfo->narHash = hashString(htSHA256, *nar);
 
-  if (info.narHash && info.narHash != narInfo->narHash)
+  if (info.narHash && info.narHash != narInfo->narHash) {
     throw Error(
         format("refusing to copy corrupted path '%1%' to binary cache") %
         info.path);
+  }
 
   auto accessor_ = std::dynamic_pointer_cast<RemoteFSAccessor>(accessor);
 
@@ -203,8 +209,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info,
   if (repair || !fileExists(narInfo->url)) {
     stats.narWrite++;
     upsertFile(narInfo->url, *narCompressed, "application/x-nix-nar");
-  } else
+  } else {
     stats.narWriteAverted++;
+  }
 
   stats.narWriteBytes += nar->size();
   stats.narWriteCompressedBytes += narCompressed->size();
@@ -349,9 +356,9 @@ void BinaryCacheStore::addSignatures(const Path& storePath,
 std::shared_ptr<std::string> BinaryCacheStore::getBuildLog(const Path& path) {
   Path drvPath;
 
-  if (isDerivation(path))
+  if (isDerivation(path)) {
     drvPath = path;
-  else {
+  } else {
     try {
       auto info = queryPathInfo(path);
       // FIXME: add a "Log" field to .narinfo