diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index b56f3ee8a..642da9f04 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -14,10 +14,8 @@ namespace nix { -BinaryCacheStore::BinaryCacheStore(std::shared_ptr localStore, - const StoreParams & params) - : localStore(localStore) - , compression(get(params, "compression", "xz")) +BinaryCacheStore::BinaryCacheStore(const StoreParams & params) + : compression(get(params, "compression", "xz")) { auto secretKeyFile = get(params, "secret-key", ""); if (secretKeyFile != "") @@ -170,30 +168,6 @@ std::shared_ptr BinaryCacheStore::queryPathInfoUncached(const Pat return std::shared_ptr(narInfo); } -void BinaryCacheStore::querySubstitutablePathInfos(const PathSet & paths, - SubstitutablePathInfos & infos) -{ - PathSet left; - - if (!localStore) return; - - for (auto & storePath : paths) { - try { - auto info = localStore->queryPathInfo(storePath); - SubstitutablePathInfo sub; - sub.references = info->references; - sub.downloadSize = 0; - sub.narSize = info->narSize; - infos.emplace(storePath, sub); - } catch (InvalidPath &) { - left.insert(storePath); - } - } - - if (settings.useSubstitutes) - localStore->querySubstitutablePathInfos(left, infos); -} - Path BinaryCacheStore::addToStore(const string & name, const Path & srcPath, bool recursive, HashType hashAlgo, PathFilter & filter, bool repair) { @@ -237,39 +211,6 @@ Path BinaryCacheStore::addTextToStore(const string & name, const string & s, return info.path; } -void BinaryCacheStore::buildPaths(const PathSet & paths, BuildMode buildMode) -{ - for (auto & storePath : paths) { - assert(!isDerivation(storePath)); - - if (isValidPath(storePath)) continue; - - if (!localStore) - throw Error(format("don't know how to realise path ‘%1%’ in a binary cache") % storePath); - - localStore->addTempRoot(storePath); - - if (!localStore->isValidPath(storePath)) - localStore->ensurePath(storePath); - - auto info = localStore->queryPathInfo(storePath); - - for (auto & ref : info->references) - if (ref != storePath) - ensurePath(ref); - - StringSink sink; - dumpPath(storePath, sink); - - addToStore(*info, *sink.s, buildMode == bmRepair); - } -} - -void BinaryCacheStore::ensurePath(const Path & path) -{ - buildPaths({path}); -} - /* Given requests for a path /nix/store//, this accessor will first download the NAR for /nix/store/ from the binary cache, build a NAR accessor for that NAR, and use that to access . */ diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index cc6b98525..bb67a8581 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -17,14 +17,11 @@ private: std::unique_ptr secretKey; - std::shared_ptr localStore; - std::string compression; protected: - BinaryCacheStore(std::shared_ptr localStore, - const StoreParams & params); + BinaryCacheStore(const StoreParams & params); [[noreturn]] void notImpl(); @@ -78,7 +75,8 @@ public: { return {}; } void querySubstitutablePathInfos(const PathSet & paths, - SubstitutablePathInfos & infos) override; + SubstitutablePathInfos & infos) + { } void addToStore(const ValidPathInfo & info, const std::string & nar, bool repair = false) override; @@ -92,13 +90,15 @@ public: void narFromPath(const Path & path, Sink & sink) override; - void buildPaths(const PathSet & paths, BuildMode buildMode = bmNormal) override; + void buildPaths(const PathSet & paths, BuildMode buildMode = bmNormal) override + { notImpl(); } BuildResult buildDerivation(const Path & drvPath, const BasicDerivation & drv, BuildMode buildMode = bmNormal) override { notImpl(); } - void ensurePath(const Path & path) override; + void ensurePath(const Path & path) override + { notImpl(); } void addTempRoot(const Path & path) override { notImpl(); } diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 92d94aeea..073f76cc9 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -15,9 +15,9 @@ private: public: - HttpBinaryCacheStore(std::shared_ptr localStore, + HttpBinaryCacheStore( const StoreParams & params, const Path & _cacheUri) - : BinaryCacheStore(localStore, params) + : BinaryCacheStore(params) , cacheUri(_cacheUri) , downloaders( std::numeric_limits::max(), @@ -91,8 +91,7 @@ static RegisterStoreImplementation regStore([]( { if (std::string(uri, 0, 7) != "http://" && std::string(uri, 0, 8) != "https://") return 0; - auto store = std::make_shared(std::shared_ptr(0), - params, uri); + auto store = std::make_shared(params, uri); store->init(); return store; }); diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc index 2c2944938..e979a94b7 100644 --- a/src/libstore/local-binary-cache-store.cc +++ b/src/libstore/local-binary-cache-store.cc @@ -11,9 +11,9 @@ private: public: - LocalBinaryCacheStore(std::shared_ptr localStore, + LocalBinaryCacheStore( const StoreParams & params, const Path & binaryCacheDir) - : BinaryCacheStore(localStore, params) + : BinaryCacheStore(params) , binaryCacheDir(binaryCacheDir) { } @@ -90,8 +90,7 @@ static RegisterStoreImplementation regStore([]( -> std::shared_ptr { if (std::string(uri, 0, 7) != "file://") return 0; - auto store = std::make_shared( - std::shared_ptr(0), params, std::string(uri, 7)); + auto store = std::make_shared(params, std::string(uri, 7)); store->init(); return store; }); diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index e64d0eb85..bd8abe482 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -46,9 +46,9 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore Stats stats; - S3BinaryCacheStoreImpl(std::shared_ptr localStore, + S3BinaryCacheStoreImpl( const StoreParams & params, const std::string & bucketName) - : S3BinaryCacheStore(localStore, params) + : S3BinaryCacheStore(params) , bucketName(bucketName) , config(makeConfig()) , client(make_ref(*config)) @@ -248,8 +248,7 @@ static RegisterStoreImplementation regStore([]( -> std::shared_ptr { if (std::string(uri, 0, 5) != "s3://") return 0; - auto store = std::make_shared(std::shared_ptr(0), - params, std::string(uri, 5)); + auto store = std::make_shared(params, std::string(uri, 5)); store->init(); return store; }); diff --git a/src/libstore/s3-binary-cache-store.hh b/src/libstore/s3-binary-cache-store.hh index 2751a9d01..3f9bd8912 100644 --- a/src/libstore/s3-binary-cache-store.hh +++ b/src/libstore/s3-binary-cache-store.hh @@ -10,9 +10,8 @@ class S3BinaryCacheStore : public BinaryCacheStore { protected: - S3BinaryCacheStore(std::shared_ptr localStore, - const StoreParams & params) - : BinaryCacheStore(localStore, params) + S3BinaryCacheStore(const StoreParams & params) + : BinaryCacheStore(params) { } public: