Skip to content

Commit 3b5d1ed

Browse files
committed
Revert the original "#ns" suffix hack
Now that the Cleaner is "tag namespace aware", the fs tag iterator does not need to return tags that belong to another namespace. It does however need to recognize and skip files that represent tags in another namespace. But now it will once again impossible to name a tag with a path that would put it in a different namespace. Signed-off-by: J Robert Ray <[email protected]>
1 parent a1a917d commit 3b5d1ed

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

crates/spfs/src/storage/fs/tag.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl Stream for TagStreamIter {
491491
use TagStreamIterState::*;
492492
match self.state.take() {
493493
// TODO: this walkdir loop is not actually async and should be fixed
494-
Some(WalkingTree) => loop {
494+
Some(WalkingTree) => 'entry: loop {
495495
let entry = self.inner.next();
496496
match entry {
497497
None => break Ready(None),
@@ -510,6 +510,28 @@ impl Stream for TagStreamIter {
510510
if path.extension() != Some(OsStr::new(TAG_EXT)) {
511511
continue;
512512
}
513+
514+
// This iterator skips over any namespaces; since the
515+
// walkdir iterator will descend into any directory,
516+
// the whole parent hierarchy needs to be checked for
517+
// the namespace marker.
518+
//
519+
// The root itself may be a namespace.
520+
let mut parent = path.parent();
521+
while let Some(p) = parent {
522+
if p == self.root {
523+
break;
524+
}
525+
if p.file_name()
526+
.and_then(|s| s.to_str())
527+
.map(|p| p.ends_with(TAG_NAMESPACE_MARKER))
528+
.unwrap_or_default()
529+
{
530+
continue 'entry;
531+
}
532+
parent = p.parent();
533+
}
534+
513535
let spec = match tag_from_path(&path, &self.root) {
514536
Err(err) => break Ready(Some(Err(err))),
515537
Ok(spec) => spec,

crates/spfs/src/tracking/tag.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ fn _find_org_error(org: &str) -> Option<usize> {
353353
for (i, ch) in org.chars().enumerate() {
354354
match ch {
355355
'-' | '_' | '.' | '/' => (),
356-
'#' if &org[i..] == "#ns" => return None,
357356
_ => {
358357
if !ch.is_ascii_alphanumeric() {
359358
return Some(i);

0 commit comments

Comments
 (0)