Skip to content

Commit

Permalink
Fix path cache .remove_file and .remove_dir implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
white-axe committed Jul 15, 2024
1 parent f011b25 commit 553f072
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions crates/filesystem/src/path_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,13 @@ where

self.fs.remove_dir(&path).wrap_err_with(|| c.clone())?;

// Remove the directory and its contents from `cache.trie` and `cache.cactus`
{
let cache = &mut *cache;

let mut path = to_lowercase(path);
path.set_extension("");

for extension_trie in cache.trie.iter_prefix(&path).unwrap().map(|(_, t)| t) {
for index in extension_trie.values().copied() {
cache.cactus.remove(index);
Expand All @@ -490,14 +495,19 @@ where

self.fs.remove_file(&path).wrap_err_with(|| c.clone())?;

// Remove the file from `cache.trie` and `cache.cactus`
{
let cache = &mut *cache;
for extension_trie in cache.trie.iter_prefix(&path).unwrap().map(|(_, t)| t) {
for index in extension_trie.values().copied() {
cache.cactus.remove(index);
}

let mut path = to_lowercase(path);
path.set_extension("");
let path = with_trie_suffix(&path);

let extension_trie = cache.trie.get_file(&path).unwrap();
for index in extension_trie.values().copied() {
cache.cactus.remove(index);
}
cache.trie.remove_dir(&path);
cache.trie.remove_file(&path);
}

Ok(())
Expand Down

0 comments on commit 553f072

Please sign in to comment.