mirror of
https://github.com/NixOS/nix
synced 2025-07-02 21:51:50 +02:00
Store parsed hashes in DerivationOutput
It's best to detect invalid data as soon as possible, with data types that make storing it impossible.
This commit is contained in:
parent
f5494d9442
commit
832bd534dc
8 changed files with 128 additions and 63 deletions
|
@ -12,20 +12,31 @@ namespace nix {
|
|||
|
||||
/* Abstract syntax of derivations. */
|
||||
|
||||
/// Pair of a hash, and how the file system was ingested
|
||||
struct FileSystemHash {
|
||||
FileIngestionMethod method;
|
||||
Hash hash;
|
||||
FileSystemHash(FileIngestionMethod method, Hash hash)
|
||||
: method(std::move(method))
|
||||
, hash(std::move(hash))
|
||||
{ }
|
||||
FileSystemHash(const FileSystemHash &) = default;
|
||||
FileSystemHash(FileSystemHash &&) = default;
|
||||
FileSystemHash & operator = (const FileSystemHash &) = default;
|
||||
std::string printMethodAlgo() const;
|
||||
};
|
||||
|
||||
struct DerivationOutput
|
||||
{
|
||||
StorePath path;
|
||||
std::string hashAlgo; /* hash used for expected hash computation */
|
||||
std::string hash; /* expected hash, may be null */
|
||||
DerivationOutput(StorePath && path, std::string && hashAlgo, std::string && hash)
|
||||
std::optional<FileSystemHash> hash; /* hash used for expected hash computation */
|
||||
DerivationOutput(StorePath && path, std::optional<FileSystemHash> && hash)
|
||||
: path(std::move(path))
|
||||
, hashAlgo(std::move(hashAlgo))
|
||||
, hash(std::move(hash))
|
||||
{ }
|
||||
DerivationOutput(const DerivationOutput &) = default;
|
||||
DerivationOutput(DerivationOutput &&) = default;
|
||||
DerivationOutput & operator = (const DerivationOutput &) = default;
|
||||
void parseHashInfo(FileIngestionMethod & recursive, Hash & hash) const;
|
||||
};
|
||||
|
||||
typedef std::map<string, DerivationOutput> DerivationOutputs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue