about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/local-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/local-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/local-binary-cache-store.cc')
-rw-r--r--third_party/nix/src/libstore/local-binary-cache-store.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/third_party/nix/src/libstore/local-binary-cache-store.cc b/third_party/nix/src/libstore/local-binary-cache-store.cc
index 925fb34de48f..29c74cedd834 100644
--- a/third_party/nix/src/libstore/local-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/local-binary-cache-store.cc
@@ -26,9 +26,10 @@ class LocalBinaryCacheStore : public BinaryCacheStore {
     try {
       readFile(binaryCacheDir + "/" + path, sink);
     } catch (SysError& e) {
-      if (e.errNo == ENOENT)
+      if (e.errNo == ENOENT) {
         throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache",
                                     path);
+      }
     }
   }
 
@@ -36,8 +37,9 @@ class LocalBinaryCacheStore : public BinaryCacheStore {
     PathSet paths;
 
     for (auto& entry : readDirectory(binaryCacheDir)) {
-      if (entry.name.size() != 40 || !hasSuffix(entry.name, ".narinfo"))
+      if (entry.name.size() != 40 || !hasSuffix(entry.name, ".narinfo")) {
         continue;
+      }
       paths.insert(storeDir + "/" +
                    entry.name.substr(0, entry.name.size() - 8));
     }
@@ -55,8 +57,9 @@ static void atomicWrite(const Path& path, const std::string& s) {
   Path tmp = path + ".tmp." + std::to_string(getpid());
   AutoDelete del(tmp, false);
   writeFile(tmp, s);
-  if (rename(tmp.c_str(), path.c_str()))
+  if (rename(tmp.c_str(), path.c_str())) {
     throw SysError(format("renaming '%1%' to '%2%'") % tmp % path);
+  }
   del.cancel();
 }
 
@@ -74,8 +77,9 @@ static RegisterStoreImplementation regStore(
     [](const std::string& uri,
        const Store::Params& params) -> std::shared_ptr<Store> {
       if (getEnv("_NIX_FORCE_HTTP_BINARY_CACHE_STORE") == "1" ||
-          std::string(uri, 0, 7) != "file://")
+          std::string(uri, 0, 7) != "file://") {
         return 0;
+      }
       auto store =
           std::make_shared<LocalBinaryCacheStore>(params, std::string(uri, 7));
       store->init();