forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out
VisibleStore
and ReferrersStore
from Store
More progress on issue NixOS#5729 `queryAllValidPaths` and `queryReferrers` were two methods that failing `unsupported` default implementation. This is not type safe. Now, those methods are in their own classes, and there is no more `unsupported` default instances of them. (I thought we could get away with one class for both, but sadly that is not quite the case: `LocalBinaryCacheStore` and `S3BinaryCacheStore` implement the former but the latter.)
- Loading branch information
1 parent
ef0b483
commit 4a7f9b7
Showing
12 changed files
with
123 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
///@file | ||
|
||
#include "visible-store.hh" | ||
|
||
namespace nix { | ||
|
||
/** | ||
* A store that allows querying referrers. | ||
* | ||
* The referrers relation is the dual of the references relation, the | ||
* latter being the "regular" one we are usually interested in. | ||
* | ||
* This is no inherent reason why this should be a subclass of | ||
* `VisibleStore`; it just so happens that every extent store object we | ||
* have to day that implements `queryReferrers()` also implements | ||
* `queryAllValidPaths()`. If that ceases to be the case, we can revisit | ||
* this; until this having this interface inheritance means fewer | ||
* interface combinations to think about. | ||
*/ | ||
struct ReferrersStore : virtual VisibleStore | ||
{ | ||
inline static std::string operationName = "Query referrers"; | ||
|
||
/** | ||
* Queries the set of incoming FS references for a store path. | ||
* The result is not cleared. | ||
* | ||
* @param path The path of the store object we care about incoming | ||
* references to. | ||
* | ||
* @param [out] referrers The set in which to collect the referrers | ||
* of `path`. | ||
*/ | ||
virtual void queryReferrers(const StorePath & path, StorePathSet & referrers) = 0; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
///@file | ||
|
||
#include "store-api.hh" | ||
|
||
namespace nix { | ||
|
||
/** | ||
* A Store that exposes all store objects. | ||
* | ||
* ### Privacy and Security | ||
* | ||
* For the base `Store` class, we aim for `StorePath`s to act as | ||
* capabilities: only store objects which are reachable from the store | ||
* objects the user has (i.e. those directly-referenced objects and | ||
* their reference closure). | ||
* | ||
* A `VisibleStore` breaks this by exposing these methods that allow | ||
* discovering other store objects, outside the "reachable set" as | ||
* defined above. This is necessary to implement certain operations, but | ||
* care must taken exposing this functionality to the user as it makes | ||
* e.g. secret management and other security properties trickier to get | ||
* right. | ||
*/ | ||
struct VisibleStore : virtual Store | ||
{ | ||
inline static std::string operationName = "Query all valid paths"; | ||
|
||
/** | ||
* Query the set of all valid paths. Note that for some store | ||
* backends, the name part of store paths may be replaced by 'x' | ||
* (i.e. you'll get `/nix/store/<hash>-x` rather than | ||
* `/nix/store/<hash>-<name>`). Use `queryPathInfo()` to obtain the | ||
* full store path. | ||
* | ||
* \todo should return a set of `std::variant<StorePath, HashPart>` | ||
* to get rid of this hack. | ||
*/ | ||
virtual StorePathSet queryAllValidPaths() = 0; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters