diff --git a/crates/spfs/src/proto/conversions.rs b/crates/spfs/src/proto/conversions.rs index bc7de70ae7..9a969fa411 100644 --- a/crates/spfs/src/proto/conversions.rs +++ b/crates/spfs/src/proto/conversions.rs @@ -330,11 +330,8 @@ impl From<&storage::EntryType> for super::ls_tags_response::Entry { storage::EntryType::Folder(e) => { super::ls_tags_response::entry::Kind::Folder(e.to_owned()) } - storage::EntryType::Namespace { name, depth } => { - super::ls_tags_response::entry::Kind::Namespace(super::TagNamespace { - name: name.to_owned(), - depth: *depth, - }) + storage::EntryType::Namespace(e) => { + super::ls_tags_response::entry::Kind::Namespace(e.to_owned()) } storage::EntryType::Tag(e) => { super::ls_tags_response::entry::Kind::Tag(e.to_owned()) @@ -353,10 +350,7 @@ impl TryFrom for storage::EntryType { Ok(storage::EntryType::Folder(e)) } super::ls_tags_response::entry::Kind::Namespace(e) => { - Ok(storage::EntryType::Namespace { - name: e.name, - depth: e.depth, - }) + Ok(storage::EntryType::Namespace(e)) } super::ls_tags_response::entry::Kind::Tag(e) => Ok(storage::EntryType::Tag(e)), }, diff --git a/crates/spfs/src/proto/defs/tag.proto b/crates/spfs/src/proto/defs/tag.proto index b52cb53e52..bf0ca4b368 100644 --- a/crates/spfs/src/proto/defs/tag.proto +++ b/crates/spfs/src/proto/defs/tag.proto @@ -17,18 +17,13 @@ message Tag { DateTime time = 6; } -message TagNamespace { - string name = 1; - uint64 depth = 2; -} - message LsTagsRequest { string path = 1; } message LsTagsResponse { message Entry { oneof kind { string folder = 1; string tag = 2; - TagNamespace namespace = 3; + string namespace = 3; } } message EntryList { diff --git a/crates/spfs/src/storage/fs/tag.rs b/crates/spfs/src/storage/fs/tag.rs index 024d083e3e..158553c1ab 100644 --- a/crates/spfs/src/storage/fs/tag.rs +++ b/crates/spfs/src/storage/fs/tag.rs @@ -28,18 +28,16 @@ impl FSRepository { fn tags_root(&self) -> PathBuf { let mut tags_root = self.root().join("tags"); if let Some(tag_namespace) = self.get_tag_namespace() { - for (index, component) in tag_namespace.components().enumerate() { + for component in tag_namespace.components() { // Assuming the tag namespace is only made up of `Normal` // elements (validated elsewhere). let Component::Normal(component) = component else { continue; }; - // Add a suffix in the form of `"#ns."` to distinguish - // tag namespace subdirectories from normal tag subdirectories, - // and to disambiguate some tag namespaces having a common - // directory prefix with another namespace. - tags_root = tags_root.join(format!("{}#ns.{index}", component.to_string_lossy())); + // Add a suffix in the form of `"#ns"` to distinguish + // tag namespace subdirectories from normal tag subdirectories. + tags_root = tags_root.join(format!("{}#ns", component.to_string_lossy())); } } tags_root @@ -92,16 +90,8 @@ impl TagStorage for FSRepository { } else if entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false) { path.file_name().map(|s| { let s = s.to_string_lossy(); - match s.split_once("#ns.") { - Some((name, depth)) => Ok(EntryType::Namespace { - name: name.to_owned(), - depth: depth.parse().map_err(|err| { - Error::String(format!( - "Failed to parse depth number in tag namespace '{}': {err}", - s - )) - })?, - }), + match s.split_once("#ns") { + Some((name, _)) => Ok(EntryType::Namespace(name.to_owned())), None => Ok(EntryType::Folder(s.to_string())), } }) diff --git a/crates/spfs/src/storage/tag.rs b/crates/spfs/src/storage/tag.rs index 1bb55a6de1..b7d3dd44c1 100644 --- a/crates/spfs/src/storage/tag.rs +++ b/crates/spfs/src/storage/tag.rs @@ -24,7 +24,7 @@ mod tag_test; #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum EntryType { Folder(String), - Namespace { name: String, depth: u64 }, + Namespace(String), Tag(String), } @@ -32,7 +32,7 @@ impl AsRef for EntryType { fn as_ref(&self) -> &str { match self { Self::Folder(s) => s, - Self::Namespace { name, .. } => name, + Self::Namespace(s) => s, Self::Tag(s) => s, } } @@ -42,7 +42,7 @@ impl Display for EntryType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { match self { EntryType::Folder(e) => f.pad(format!("{e}/").as_str()), - EntryType::Namespace { name, depth } => f.pad(format!("{name}#ns.{depth}/").as_str()), + EntryType::Namespace(e) => f.pad(format!("{e}#ns/").as_str()), EntryType::Tag(e) => f.pad(e), } } diff --git a/crates/spfs/src/storage/tag_test.rs b/crates/spfs/src/storage/tag_test.rs index faebdeb1af..6adc1f5f17 100644 --- a/crates/spfs/src/storage/tag_test.rs +++ b/crates/spfs/src/storage/tag_test.rs @@ -358,13 +358,7 @@ async fn test_tag_in_namespace( .collect::>>() .await .unwrap(); - assert_eq!( - tags, - vec![EntryType::Namespace { - name: namespace_name.to_string(), - depth: 0 - }] - ); + assert_eq!(tags, vec![EntryType::Namespace(namespace_name.to_string())]); } #[rstest]