Skip to content

Commit

Permalink
Push addToStoreFromDump unsupported(...) down Store class hiera…
Browse files Browse the repository at this point in the history
…rchy

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 NixOS#8217. Getting close to no `unsupported` in the `Store`
interface itself!

More progress on issue NixOS#5729.
  • Loading branch information
Ericson2314 committed Jan 18, 2024
1 parent b5ed36e commit 574db83
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/libstore/dummy-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"); }

Expand Down
9 changes: 9 additions & 0 deletions src/libstore/legacy-ssh-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 574db83

Please sign in to comment.