From 43f3d4378cbc9c69a690d40172a0603b489f6fe4 Mon Sep 17 00:00:00 2001 From: Davy Kager Date: Mon, 12 Oct 2026 22:56:30 +0200 Subject: [PATCH] Fix in-memory filesystem lookups on Windows add_in_memory_file stored the path exactly as given (e.g. with "/"), while lookups go through get_in_memory_key, which rebuilds the path and uses "\" on Windows. The keys never matched there, so shim_filesystem::tests::in_memory_filesystem_shim always failed on Windows. Store file and directory keys through get_in_memory_key as well. Co-Authored-By: Claude Opus 5.5 --- src/shim_filesystem.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/shim_filesystem.rs b/src/shim_filesystem.rs index d539a6300..459a1c5b8 100644 --- a/src/shim_filesystem.rs +++ b/src/shim_filesystem.rs @@ -288,19 +288,21 @@ cfg_if! { static IN_MEMORY_DIRS: RwLock>> = RwLock::new(None); pub fn add_in_memory_file(path: &str, content: &str) { + // store the keys the same way they are looked up (get_in_memory_key), so that "/" in 'path' + // still matches on Windows, where the lookup key is built with "\" + let path_obj = Path::new(path); { let mut files = IN_MEMORY_FILES.write().unwrap(); - files.get_or_insert_with(HashMap::new).insert(path.to_string(), content.to_string()); + files.get_or_insert_with(HashMap::new).insert(get_in_memory_key(path_obj), content.to_string()); } - let path_obj = Path::new(path); { let mut dirs = IN_MEMORY_DIRS.write().unwrap(); let dirs = dirs.get_or_insert_with(HashSet::new); for parent in path_obj.ancestors().skip(1) { - let parent_str = parent.to_str().unwrap_or_default(); + let parent_str = get_in_memory_key(parent); if !parent_str.is_empty() { - dirs.insert(parent_str.to_string()); + dirs.insert(parent_str); } } }