mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Factor out UnkeyedValidPathInfo
and test
This makes the path info serialisers ideomatic again, which allows me to test them.
This commit is contained in:
parent
596bd469cc
commit
70f8b96c11
10 changed files with 218 additions and 34 deletions
|
@ -32,9 +32,8 @@ struct SubstitutablePathInfo
|
|||
typedef std::map<StorePath, SubstitutablePathInfo> SubstitutablePathInfos;
|
||||
|
||||
|
||||
struct ValidPathInfo
|
||||
struct UnkeyedValidPathInfo
|
||||
{
|
||||
StorePath path;
|
||||
std::optional<StorePath> deriver;
|
||||
/**
|
||||
* \todo document this
|
||||
|
@ -72,6 +71,20 @@ struct ValidPathInfo
|
|||
*/
|
||||
std::optional<ContentAddress> ca;
|
||||
|
||||
UnkeyedValidPathInfo(const UnkeyedValidPathInfo & other) = default;
|
||||
|
||||
UnkeyedValidPathInfo(Hash narHash) : narHash(narHash) { };
|
||||
|
||||
DECLARE_CMP(UnkeyedValidPathInfo);
|
||||
|
||||
virtual ~UnkeyedValidPathInfo() { }
|
||||
};
|
||||
|
||||
struct ValidPathInfo : UnkeyedValidPathInfo {
|
||||
StorePath path;
|
||||
|
||||
DECLARE_CMP(ValidPathInfo);
|
||||
|
||||
/**
|
||||
* Return a fingerprint of the store path to be used in binary
|
||||
* cache signatures. It contains the store path, the base-32
|
||||
|
@ -84,11 +97,11 @@ struct ValidPathInfo
|
|||
|
||||
void sign(const Store & store, const SecretKey & secretKey);
|
||||
|
||||
/**
|
||||
* @return The `ContentAddressWithReferences` that determines the
|
||||
* store path for a content-addressed store object, `std::nullopt`
|
||||
* for an input-addressed store object.
|
||||
*/
|
||||
/**
|
||||
* @return The `ContentAddressWithReferences` that determines the
|
||||
* store path for a content-addressed store object, `std::nullopt`
|
||||
* for an input-addressed store object.
|
||||
*/
|
||||
std::optional<ContentAddressWithReferences> contentAddressWithReferences() const;
|
||||
|
||||
/**
|
||||
|
@ -114,8 +127,8 @@ struct ValidPathInfo
|
|||
|
||||
ValidPathInfo(const ValidPathInfo & other) = default;
|
||||
|
||||
ValidPathInfo(StorePath && path, Hash narHash) : path(std::move(path)), narHash(narHash) { };
|
||||
ValidPathInfo(const StorePath & path, Hash narHash) : path(path), narHash(narHash) { };
|
||||
ValidPathInfo(StorePath && path, UnkeyedValidPathInfo info) : UnkeyedValidPathInfo(info), path(std::move(path)) { };
|
||||
ValidPathInfo(const StorePath & path, UnkeyedValidPathInfo info) : UnkeyedValidPathInfo(info), path(path) { };
|
||||
|
||||
ValidPathInfo(const Store & store,
|
||||
std::string_view name, ContentAddressWithReferences && ca, Hash narHash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue