diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-30T11·33+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-30T13·18+0200 |
commit | e2224844019d58fc947ce00e18e9fa9974d2c8b5 (patch) | |
tree | 20204fa548e7a926e838486c63250572f4d6c2e8 /src/libstore/binary-cache-store.cc | |
parent | b66ab6cdbce5f4ac2db8976872547680242166e8 (diff) |
Re-implement the WantMassQuery property of binary caches
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 642da9f0477e..58cb87a516b9 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -29,8 +29,27 @@ BinaryCacheStore::BinaryCacheStore(const StoreParams & params) void BinaryCacheStore::init() { std::string cacheInfoFile = "nix-cache-info"; - if (!fileExists(cacheInfoFile)) + + auto cacheInfo = getFile(cacheInfoFile); + if (!cacheInfo) { upsertFile(cacheInfoFile, "StoreDir: " + settings.nixStore + "\n"); + } else { + for (auto & line : tokenizeString<Strings>(*cacheInfo, "\n")) { + size_t colon = line.find(':'); + 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") { + if (value != settings.nixStore) + throw Error(format("binary cache ‘%s’ is for Nix stores with prefix ‘%s’, not ‘%s’") + % getUri() % value % settings.nixStore); + } else if (name == "WantMassQuery") { + wantMassQuery_ = value == "1"; + } else if (name == "Priority") { + string2Int(value, priority); + } + } + } } void BinaryCacheStore::notImpl() |