feat(tvix/store): rename and expose StorePath::validate_name
Change-Id: I8a16c214c7c644756d9d54187beba8c80ccfb39c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7853 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
6e7f06d942
commit
0f7e4bec66
1 changed files with 3 additions and 2 deletions
|
@ -64,7 +64,7 @@ impl StorePath {
|
|||
return Err(ParseStorePathError::MissingDash());
|
||||
}
|
||||
|
||||
StorePath::validate_characters(&s[ENCODED_DIGEST_SIZE + 2..])?;
|
||||
StorePath::validate_name(&s[ENCODED_DIGEST_SIZE + 2..])?;
|
||||
|
||||
Ok(StorePath {
|
||||
name: s[ENCODED_DIGEST_SIZE + 1..].to_string(),
|
||||
|
@ -87,7 +87,8 @@ impl StorePath {
|
|||
format!("{}/{}", STORE_DIR, self)
|
||||
}
|
||||
|
||||
fn validate_characters(s: &str) -> Result<(), ParseStorePathError> {
|
||||
/// Checks a given &str to match the restrictions for store path names.
|
||||
pub fn validate_name(s: &str) -> Result<(), ParseStorePathError> {
|
||||
for c in s.chars() {
|
||||
if c.is_ascii_alphanumeric()
|
||||
|| c == '-'
|
||||
|
|
Loading…
Reference in a new issue