From ba0a81d14f1c3d0635d4b6cad47e4e26b5c5a6ca Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Feb 2016 14:57:30 +0100 Subject: [PATCH] Show a proper error message for unimplemented binary cache operations --- src/libstore/binary-cache-store.cc | 5 +++++ src/libstore/binary-cache-store.hh | 36 ++++++++++++++++-------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 6bea0e6c9..6d40c70a3 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -33,6 +33,11 @@ void BinaryCacheStore::init() upsertFile(cacheInfoFile, "StoreDir: " + settings.nixStore + "\n"); } +void BinaryCacheStore::notImpl() +{ + throw Error("operation not implemented for binary cache stores"); +} + const BinaryCacheStore::Stats & BinaryCacheStore::getStats() { return stats; diff --git a/src/libstore/binary-cache-store.hh b/src/libstore/binary-cache-store.hh index d02f46dea..0b343b357 100644 --- a/src/libstore/binary-cache-store.hh +++ b/src/libstore/binary-cache-store.hh @@ -34,6 +34,8 @@ protected: BinaryCacheStore(std::shared_ptr localStore, const Path & secretKeyFile, const Path & publicKeyFile); + [[noreturn]] void notImpl(); + virtual bool fileExists(const std::string & path) = 0; virtual void upsertFile(const std::string & path, const std::string & data) = 0; @@ -79,37 +81,37 @@ public: bool isValidPath(const Path & path) override; PathSet queryValidPaths(const PathSet & paths) override - { abort(); } + { notImpl(); } PathSet queryAllValidPaths() override - { abort(); } + { notImpl(); } ValidPathInfo queryPathInfo(const Path & path) override; Hash queryPathHash(const Path & path) override - { abort(); } + { notImpl(); } void queryReferrers(const Path & path, PathSet & referrers) override - { abort(); } + { notImpl(); } Path queryDeriver(const Path & path) override - { abort(); } + { notImpl(); } PathSet queryValidDerivers(const Path & path) override - { abort(); } + { notImpl(); } PathSet queryDerivationOutputs(const Path & path) override - { abort(); } + { notImpl(); } StringSet queryDerivationOutputNames(const Path & path) override - { abort(); } + { notImpl(); } Path queryPathFromHashPart(const string & hashPart) override - { abort(); } + { notImpl(); } PathSet querySubstitutablePaths(const PathSet & paths) override - { abort(); } + { notImpl(); } void querySubstitutablePathInfos(const PathSet & paths, SubstitutablePathInfos & infos) override; @@ -117,11 +119,11 @@ public: Path addToStore(const string & name, const Path & srcPath, bool recursive = true, HashType hashAlgo = htSHA256, PathFilter & filter = defaultPathFilter, bool repair = false) override - { abort(); } + { notImpl(); } Path addTextToStore(const string & name, const string & s, const PathSet & references, bool repair = false) override - { abort(); } + { notImpl(); } void exportPath(const Path & path, bool sign, Sink & sink) override; @@ -134,24 +136,24 @@ public: BuildResult buildDerivation(const Path & drvPath, const BasicDerivation & drv, BuildMode buildMode = bmNormal) override - { abort(); } + { notImpl(); } void ensurePath(const Path & path) override; void addTempRoot(const Path & path) override - { abort(); } + { notImpl(); } void addIndirectRoot(const Path & path) override - { abort(); } + { notImpl(); } void syncWithGC() override { } Roots findRoots() override - { abort(); } + { notImpl(); } void collectGarbage(const GCOptions & options, GCResults & results) override - { abort(); } + { notImpl(); } PathSet queryFailedPaths() override { return PathSet(); }