diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-18T19·42+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-19T09·35+0000 |
commit | 3fda90602d3de7a720149f090422c4da9d12d31d (patch) | |
tree | 2d43a05d1eb9fcbdb2404d205a40ae8d21d7f89b /tvix/store | |
parent | 9c223450199b466c535f2b715ad68f1f295fa7dc (diff) |
refactor(tvix/castore): add try_into_anonymous_node, rename to try_* r/8836
We have two places where we parse protos and want their names to be empty: - Receiving a root node in a nar-bridge NAR request - Processing the CalculateNAR gRPC call We don't have any place where we want to keep a name as bytes::Bytes around, yet we used the `into_name_bytes_and_node` method. It was also a bit wrongly named - it wasn't very clear the name was not validated, and that the function may fail. This moves the "splitting off the name as bytes::Bytes" part into a private helper, only leaving the `try_into_name_and_node` and `try_into_anonymous_node` methods around. Change-Id: I2c7fd9871d49ec67450d7efa6a30d96197fb319c Reviewed-on: https://cl.tvl.fyi/c/depot/+/12664 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Marijan Petričević <marijan.petricevic94@gmail.com> Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/store')
-rw-r--r-- | tvix/store/src/proto/grpc_pathinfoservice_wrapper.rs | 4 | ||||
-rw-r--r-- | tvix/store/src/proto/mod.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tvix/store/src/proto/grpc_pathinfoservice_wrapper.rs b/tvix/store/src/proto/grpc_pathinfoservice_wrapper.rs index d003d4bdb728..4325e79d5077 100644 --- a/tvix/store/src/proto/grpc_pathinfoservice_wrapper.rs +++ b/tvix/store/src/proto/grpc_pathinfoservice_wrapper.rs @@ -77,9 +77,9 @@ where &self, request: Request<castorepb::Node>, ) -> Result<Response<proto::CalculateNarResponse>> { - let (_, root_node) = request + let root_node = request .into_inner() - .into_name_bytes_and_node() + .try_into_anonymous_node() .map_err(|e| { warn!(err = %e, "invalid root node"); Status::invalid_argument("invalid root node") diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index 807f03854ddc..d9edb81f655d 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -274,7 +274,7 @@ impl TryFrom<PathInfo> for crate::pathinfoservice::PathInfo { let (name, node) = value .node .ok_or_else(|| ValidatePathInfoError::NoNodePresent)? - .into_name_and_node() + .try_into_name_and_node() .map_err(ValidatePathInfoError::InvalidRootNode)?; Ok(Self { |