From 574db8350491d8da3f65625de1f91bc667e67360 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 17 Jan 2024 23:46:03 -0500 Subject: [PATCH] Push `addToStoreFromDump` `unsupported(...)` down `Store` class hierarchy Instead of having it be the default method in `Store` itself, have it be the implementation in `DummyStore` and `LegacySSHStore`. Then just the implementations which fail to provide the method pay the "penalty" of dealing with the icky `unimplemented` function for non-compliance. Picks up where #8217. Getting close to no `unsupported` in the `Store` interface itself! More progress on issue #5729. --- src/libstore/dummy-store.cc | 9 +++++++++ src/libstore/legacy-ssh-store.hh | 9 +++++++++ src/libstore/store-api.hh | 3 +-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libstore/dummy-store.cc b/src/libstore/dummy-store.cc index f52a309d13b..e4f13b8f410 100644 --- a/src/libstore/dummy-store.cc +++ b/src/libstore/dummy-store.cc @@ -58,6 +58,15 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store RepairFlag repair, CheckSigsFlag checkSigs) override { unsupported("addToStore"); } + virtual StorePath addToStoreFromDump( + Source & dump, + std::string_view name, + ContentAddressMethod method = FileIngestionMethod::Recursive, + HashAlgorithm hashAlgo = HashAlgorithm::SHA256, + const StorePathSet & references = StorePathSet(), + RepairFlag repair = NoRepair) override + { unsupported("addToStore"); } + void narFromPath(const StorePath & path, Sink & sink) override { unsupported("narFromPath"); } diff --git a/src/libstore/legacy-ssh-store.hh b/src/libstore/legacy-ssh-store.hh index c5a3ce67772..7cee31d66d0 100644 --- a/src/libstore/legacy-ssh-store.hh +++ b/src/libstore/legacy-ssh-store.hh @@ -69,6 +69,15 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor RepairFlag repair) override { unsupported("addToStore"); } + virtual StorePath addToStoreFromDump( + Source & dump, + std::string_view name, + ContentAddressMethod method = FileIngestionMethod::Recursive, + HashAlgorithm hashAlgo = HashAlgorithm::SHA256, + const StorePathSet & references = StorePathSet(), + RepairFlag repair = NoRepair) override + { unsupported("addToStore"); } + private: void putBuildSettings(Connection & conn); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 9667b5e9e61..b3c935db104 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -466,8 +466,7 @@ public: ContentAddressMethod method = FileIngestionMethod::Recursive, HashAlgorithm hashAlgo = HashAlgorithm::SHA256, const StorePathSet & references = StorePathSet(), - RepairFlag repair = NoRepair) - { unsupported("addToStoreFromDump"); } + RepairFlag repair = NoRepair) = 0; /** * Add a mapping indicating that `deriver!outputName` maps to the output path