Skip to content

Commit

Permalink
Push getFSAccessor unsupported(...) down Store class hierarchy
Browse files Browse the repository at this point in the history
More progress on issue NixOS#5729.

Instead of having it by 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.

Combined with my other recent PRs, this finally makes `Store` have no
`unsupported` calls!
  • Loading branch information
Ericson2314 committed Apr 13, 2023
1 parent ef0b483 commit ee97f10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/libstore/dummy-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ struct DummyStore : public virtual DummyStoreConfig, public virtual Store
void queryRealisationUncached(const DrvOutput &,
Callback<std::shared_ptr<const Realisation>> callback) noexcept override
{ callback(nullptr); }

virtual ref<FSAccessor> getFSAccessor() override
{ unsupported("getFSAccessor"); }
};

static RegisterStoreImplementation<DummyStore, DummyStoreConfig> regDummyStore;
Expand Down
3 changes: 3 additions & 0 deletions src/libstore/legacy-ssh-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
void ensurePath(const StorePath & path) override
{ unsupported("ensurePath"); }

virtual ref<FSAccessor> getFSAccessor() override
{ unsupported("getFSAccessor"); }

void computeFSClosure(const StorePathSet & paths,
StorePathSet & out, bool flipDirection = false,
bool includeOutputs = false, bool includeDerivers = false) override
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 @@ -678,8 +678,7 @@ public:
/**
* @return An object to access files in the Nix store.
*/
virtual ref<FSAccessor> getFSAccessor()
{ unsupported("getFSAccessor"); }
virtual ref<FSAccessor> getFSAccessor() = 0;

/**
* Repair the contents of the given path by redownloading it using
Expand Down

0 comments on commit ee97f10

Please sign in to comment.