diff options
author | Florian Klink <flokli@flokli.de> | 2024-08-17T19·00+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-08-18T17·22+0000 |
commit | 56fa533e438bd367aa5cae6fa505508aced42156 (patch) | |
tree | 5e2624f28f946a1753a49d8a321acd627bfc9624 /tvix/castore/src/path/mod.rs | |
parent | 0cfe2aaf6a412e495e63372c6e3f01039f371f90 (diff) |
refactor(tvix/castore): have PathComponent-specific errors r/8513
Don't use DirectoryError, but PathComponentError. Also add checks for too long path components. Change-Id: Ia9deb9dd0351138baadb2e9c9454c3e019d5a45e Reviewed-on: https://cl.tvl.fyi/c/depot/+/12229 Tested-by: BuildkiteCI Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com> Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/castore/src/path/mod.rs')
-rw-r--r-- | tvix/castore/src/path/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tvix/castore/src/path/mod.rs b/tvix/castore/src/path/mod.rs index 5a68f1add416..15f31a570da9 100644 --- a/tvix/castore/src/path/mod.rs +++ b/tvix/castore/src/path/mod.rs @@ -9,7 +9,7 @@ use std::{ }; mod component; -pub use component::PathComponent; +pub use component::{PathComponent, PathComponentError}; /// Represents a Path in the castore model. /// These are always relative, and platform-independent, which distinguishes @@ -37,7 +37,7 @@ impl Path { if !bytes.is_empty() { // Ensure all components are valid castore node names. for component in bytes.split_str(b"/") { - if !component::is_valid_name(component) { + if component::validate_name(component).is_err() { return None; } } @@ -233,7 +233,7 @@ impl PathBuf { /// Adjoins `name` to self. pub fn try_push(&mut self, name: &[u8]) -> Result<(), std::io::Error> { - if !component::is_valid_name(name) { + if component::validate_name(name).is_err() { return Err(std::io::ErrorKind::InvalidData.into()); } |