mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
Cleanup ContentAddressMethod to match docs
The old `std::variant` is bad because we aren't adding a new case to `FileIngestionMethod` so much as we are defining a separate concept --- store object content addressing rather than file system object content addressing. As such, it is more correct to just create a fresh enumeration. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
64e599ebe1
commit
b51e161af5
25 changed files with 275 additions and 203 deletions
|
|
@ -392,8 +392,9 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
|||
else {
|
||||
if (repair) throw Error("repairing is not supported when building through the Nix daemon protocol < 1.25");
|
||||
|
||||
std::visit(overloaded {
|
||||
[&](const TextIngestionMethod & thm) -> void {
|
||||
switch (caMethod.raw) {
|
||||
case ContentAddressMethod::Raw::Text:
|
||||
{
|
||||
if (hashAlgo != HashAlgorithm::SHA256)
|
||||
throw UnimplementedError("When adding text-hashed data called '%s', only SHA-256 is supported but '%s' was given",
|
||||
name, printHashAlgo(hashAlgo));
|
||||
|
|
@ -401,8 +402,14 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
|||
conn->to << WorkerProto::Op::AddTextToStore << name << s;
|
||||
WorkerProto::write(*this, *conn, references);
|
||||
conn.processStderr();
|
||||
},
|
||||
[&](const FileIngestionMethod & fim) -> void {
|
||||
break;
|
||||
}
|
||||
case ContentAddressMethod::Raw::Flat:
|
||||
case ContentAddressMethod::Raw::NixArchive:
|
||||
case ContentAddressMethod::Raw::Git:
|
||||
default:
|
||||
{
|
||||
auto fim = caMethod.getFileIngestionMethod();
|
||||
conn->to
|
||||
<< WorkerProto::Op::AddToStore
|
||||
<< name
|
||||
|
|
@ -432,9 +439,9 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
|||
} catch (EndOfFile & e) { }
|
||||
throw;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}, caMethod.raw);
|
||||
}
|
||||
auto path = parseStorePath(readString(conn->from));
|
||||
// Release our connection to prevent a deadlock in queryPathInfo().
|
||||
conn_.reset();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue