refactor(tvix/castore): have PathComponent-specific errors
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>
This commit is contained in:
parent
0cfe2aaf6a
commit
56fa533e43
6 changed files with 246 additions and 76 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue