ANW-40 Watcher: emit both deletes for a vanished .md path

A directory can be named *.md too, and a vanished path cannot be probed,
so the suffix test alone stranded its notes in the index. Emit the note
delete and the prefix delete together; the two key sets are disjoint.
This commit is contained in:
Andreas Brenner 2026-07-24 21:32:18 +03:00
parent 275c6ecfa0
commit bbb052fdc7
2 changed files with 66 additions and 9 deletions

View file

@ -194,6 +194,29 @@ mod tests {
assert!(s.get("Other/d.md").is_some());
}
#[test]
fn note_delete_and_prefix_delete_of_one_path_are_disjoint() {
// A vanished `*.md` path sends both, since it may have been a
// directory [ANW-40]. The note delete takes the key `Archive.md`,
// the prefix delete takes the keys under `Archive.md/`; neither
// reaches anything else.
let s = NoteStore::new();
s.replace(vec![
note("Archive.md"),
note("Archive.md/inner.md"),
note("Keep.md"),
]);
let dropped = s.apply_batch(
vec![],
&["Archive.md".to_string()],
&["Archive.md".to_string()],
);
assert_eq!(dropped, 1);
assert!(s.get("Archive.md").is_none());
assert!(s.get("Archive.md/inner.md").is_none());
assert!(s.get("Keep.md").is_some());
}
#[test]
fn apply_batch_prefix_delete_precedes_upserts() {
let s = NoteStore::new();