mirror of
https://github.com/NixOS/nix
synced 2025-06-29 19:03:16 +02:00
Proper parse
and render
functions for FileIngestionMethod
and ContentAddressMethod
No outward facing behavior is changed. Older methods with same names that operate on on method + algo pair (for old-style `<method>:algo`) are renamed to `*WithAlgo`.) The functions are unit-tested in the same way the names for the hash algorithms are tested.
This commit is contained in:
parent
fb5a438dca
commit
41dd9857c7
10 changed files with 162 additions and 30 deletions
|
@ -3,6 +3,31 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
FileIngestionMethod parseFileIngestionMethod(std::string_view input)
|
||||
{
|
||||
if (input == "flat") {
|
||||
return FileIngestionMethod::Flat;
|
||||
} else if (input == "nar") {
|
||||
return FileIngestionMethod::Recursive;
|
||||
} else {
|
||||
throw UsageError("Unknown file ingestion method '%s', expect `flat` or `nar`");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string_view renderFileIngestionMethod(FileIngestionMethod method)
|
||||
{
|
||||
switch (method) {
|
||||
case FileIngestionMethod::Flat:
|
||||
return "flat";
|
||||
case FileIngestionMethod::Recursive:
|
||||
return "nar";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void dumpPath(
|
||||
SourceAccessor & accessor, const CanonPath & path,
|
||||
Sink & sink,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue