refactor(tvix/store/proto): merge two match statements into one
Change-Id: I3daca008dff5527169f5916f4845234e8f3263cd Reviewed-on: https://cl.tvl.fyi/c/depot/+/9711 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
This commit is contained in:
parent
3dd5ba042b
commit
4da906bf34
1 changed files with 24 additions and 30 deletions
|
|
@ -142,19 +142,14 @@ impl PathInfo {
|
||||||
|
|
||||||
// Ensure there is a (root) node present, and it properly parses to a [StorePath].
|
// Ensure there is a (root) node present, and it properly parses to a [StorePath].
|
||||||
let root_nix_path = match &self.node {
|
let root_nix_path = match &self.node {
|
||||||
None => {
|
None | Some(castorepb::Node { node: None }) => {
|
||||||
return Err(ValidatePathInfoError::NoNodePresent());
|
Err(ValidatePathInfoError::NoNodePresent())?
|
||||||
}
|
}
|
||||||
Some(castorepb::Node { node }) => match node {
|
Some(castorepb::Node { node: Some(node) }) => {
|
||||||
None => {
|
|
||||||
return Err(ValidatePathInfoError::NoNodePresent());
|
|
||||||
}
|
|
||||||
Some(node) => {
|
|
||||||
match node {
|
match node {
|
||||||
// for a directory root node, ensure the digest has the appropriate size.
|
// for a directory root node, ensure the digest has the appropriate size.
|
||||||
castorepb::node::Node::Directory(directory_node) => {
|
castorepb::node::Node::Directory(directory_node) => {
|
||||||
if TryInto::<B3Digest>::try_into(directory_node.digest.clone()).is_err()
|
if TryInto::<B3Digest>::try_into(directory_node.digest.clone()).is_err() {
|
||||||
{
|
|
||||||
return Err(ValidatePathInfoError::InvalidNodeDigestLen(
|
return Err(ValidatePathInfoError::InvalidNodeDigestLen(
|
||||||
directory_node.digest.len(),
|
directory_node.digest.len(),
|
||||||
));
|
));
|
||||||
|
|
@ -175,7 +170,6 @@ impl PathInfo {
|
||||||
// parse the name of the node itself and return
|
// parse the name of the node itself and return
|
||||||
parse_node_name_root(node.get_name(), ValidatePathInfoError::InvalidNodeName)?
|
parse_node_name_root(node.get_name(), ValidatePathInfoError::InvalidNodeName)?
|
||||||
}
|
}
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// return the root nix path
|
// return the root nix path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue