You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On Windows, mkdir -p and add_file/add_dir key implicit parent directories with \ #2830
Version: 0.20.3, InMemoryFs, Windows host. Follow-up to #2425 / #2435.
Repro
let fs = Arc::new(InMemoryFs::new());letmut sh = Bash::builder().fs(fs.clone()).cwd("/tmp").build();
sh.exec("mkdir -p a/b; mkdir c").await?;// fs.snapshot() paths on Windows: "/tmp\a", "/tmp\a\b", "/tmp/c"
Lookups still work, because they normalize. But snapshot() exposes the \ keys, so a caller that maps snapshot paths back to / paths loses every directory that mkdir -p created.
Cause
src/fs/memory.rs builds parent paths with current.push(component) in four places:
add_file (line 935)
add_dir (line 1023)
add_lazy_file (line 1101)
recursive mkdir (line 1486)
PathBuf::push adds the host separator. #2435 closed this class for Path::join and rated the remaining push sites "normalized downstream — consistency, not a live bug". Here, though, the pushed path becomes an entry-map key directly. That's the same shape as the InMemoryFs::rename fan-out the PR fixed.
Fix
Use the helper the file already imports, at all four sites:
- current.push(component);+ current = vfs_join(¤t, component);
Tested against 0.20.3 on Windows: cargo test --lib fs:: passes 224/224, and our downstream filesystem tests pass 10/10 with this patch in place of our workaround.
Activity