Refactor local binary cache code into a subclass
[?]
Feb 18, 2016, 1:06 PM
N2NKSKHSFR6SDMGZO2ALNDVIOLOEE26BPQHCSWUGEFE3DVVVV4MACDependencies
- [2]
GH4S4AWMRename file - [3]
W2AOTSS6Rename class - [4]
24BMQDZAStart of single-process hydra-queue-runner - [5]
5AIYUMTBBasic remote building - [6]
MHVIT4JYSplit hydra-queue-runner.cc more - [7]
3FQ65IXOhydra-queue-runner: Compress binary cache NARs using xz - [8]
32HHP5CWhydra-queue-runner: Support generating a signed binary cache - [9]
73YR46NJhydra-queue-runner: Write directly to a binary cache - [10]
ENXUSMSVMake concurrency more robust - [11]
HJOEIMLRRefactor
Change contents
- replacement in src/hydra-queue-runner/Makefile.am at line 6
binary-cache-store.hh binary-cache-store.ccbinary-cache-store.hh binary-cache-store.cc \local-binary-cache-store.hh local-binary-cache-store.cc - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 12
BinaryCacheStore::BinaryCacheStore(ref<Store> localStore, const Path & binaryCacheDir,BinaryCacheStore::BinaryCacheStore(ref<Store> localStore, - edit in src/hydra-queue-runner/binary-cache-store.cc at line 15
, binaryCacheDir(binaryCacheDir) - edit in src/hydra-queue-runner/binary-cache-store.cc at line 16
createDirs(binaryCacheDir + "/nar");Path cacheInfoFile = binaryCacheDir + "/nix-cache-info";if (!pathExists(cacheInfoFile))writeFile(cacheInfoFile, "StoreDir: " + settings.nixStore + "\n"); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 26
Path BinaryCacheStore::narInfoFileFor(const Path & storePath)void BinaryCacheStore::init() - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 28
assertStorePath(storePath);return binaryCacheDir + "/" + storePathToHash(storePath) + ".narinfo";std::string cacheInfoFile = "nix-cache-info";if (!fileExists(cacheInfoFile))upsertFile(cacheInfoFile, "StoreDir: " + settings.nixStore + "\n"); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 33
void atomicWrite(const Path & path, const std::string & s)Path BinaryCacheStore::narInfoFileFor(const Path & storePath) - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 35
Path tmp = path + ".tmp." + std::to_string(getpid());AutoDelete del(tmp, false);writeFile(tmp, s);if (rename(tmp.c_str(), path.c_str()))throw SysError(format("renaming ‘%1%’ to ‘%2%’") % tmp % path);del.cancel();assertStorePath(storePath);return storePathToHash(storePath) + ".narinfo"; - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 42
Path narInfoFile = narInfoFileFor(info.path);if (pathExists(narInfoFile)) return;auto narInfoFile = narInfoFileFor(info.path);if (fileExists(narInfoFile)) return; - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 64
Path narFile = binaryCacheDir + "/" + narInfo.url;if (!pathExists(narFile)) atomicWrite(narFile, narXz);if (!fileExists(narInfo.url)) upsertFile(narInfo.url, narXz); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 69
atomicWrite(narInfoFile, narInfo.to_string());upsertFile(narInfoFile, narInfo.to_string()); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 74
Path narInfoFile = narInfoFileFor(storePath);NarInfo narInfo = NarInfo(readFile(narInfoFile), narInfoFile);auto narInfoFile = narInfoFileFor(storePath);auto narInfo = NarInfo(getFile(narInfoFile), narInfoFile); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 88
return pathExists(narInfoFileFor(storePath));return fileExists(narInfoFileFor(storePath)); - replacement in src/hydra-queue-runner/binary-cache-store.cc at line 97
auto nar = readFile(binaryCacheDir + "/" + res.url);auto nar = getFile(res.url); - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 10
class BinaryCacheStore : public nix::Storeclass BinaryCacheStore : public Store - edit in src/hydra-queue-runner/binary-cache-store.hh at line 13
- edit in src/hydra-queue-runner/binary-cache-store.hh at line 15
Path binaryCacheDir; - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 19
public:protected: - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 21
BinaryCacheStore(ref<Store> localStore, const Path & binaryCacheDir,BinaryCacheStore(ref<Store> localStore, - edit in src/hydra-queue-runner/binary-cache-store.hh at line 23
virtual bool fileExists(const std::string & path) = 0;virtual void upsertFile(const std::string & path, const std::string & data) = 0;virtual std::string getFile(const std::string & path) = 0;public: - edit in src/hydra-queue-runner/binary-cache-store.hh at line 32
virtual void init(); - replacement in src/hydra-queue-runner/binary-cache-store.hh at line 36
Path narInfoFileFor(const Path & storePath);std::string narInfoFileFor(const Path & storePath); - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 10
#include "binary-cache-store.hh"#include "local-binary-cache-store.hh" - replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 36
return make_ref<BinaryCacheStore>(getLocalStore(),auto store = make_ref<LocalBinaryCacheStore>(getLocalStore(), - edit in src/hydra-queue-runner/hydra-queue-runner.cc at line 40
store->init();return store; - file addition: local-binary-cache-store.cc[4.187]
#include "local-binary-cache-store.hh"namespace nix {LocalBinaryCacheStore::LocalBinaryCacheStore(ref<Store> localStore,const Path & binaryCacheDir, const Path & secretKeyFile, const Path & publicKeyFile): BinaryCacheStore(localStore, secretKeyFile, publicKeyFile), binaryCacheDir(binaryCacheDir){}void LocalBinaryCacheStore::init(){createDirs(binaryCacheDir + "/nar");BinaryCacheStore::init();}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()))throw SysError(format("renaming ‘%1%’ to ‘%2%’") % tmp % path);del.cancel();}bool LocalBinaryCacheStore::fileExists(const std::string & path){return pathExists(binaryCacheDir + "/" + path);}void LocalBinaryCacheStore::upsertFile(const std::string & path, const std::string & data){atomicWrite(binaryCacheDir + "/" + path, data);}std::string LocalBinaryCacheStore::getFile(const std::string & path){return readFile(binaryCacheDir + "/" + path);}} - file addition: local-binary-cache-store.hh[4.187]
#pragma once#include "binary-cache-store.hh"namespace nix {class LocalBinaryCacheStore : public BinaryCacheStore{private:Path binaryCacheDir;public:LocalBinaryCacheStore(ref<Store> localStore, const Path & binaryCacheDir,const Path & secretKeyFile, const Path & publicKeyFile);void init() override;protected:bool fileExists(const std::string & path) override;void upsertFile(const std::string & path, const std::string & data) override;std::string getFile(const std::string & path) override;};}