fs: a rename of the open file itself no longer drops the staged write

The pending commit moved to `to.join("")`, which has a trailing slash, so
the commit rename failed and the staged file was deleted.
This commit is contained in:
2026-10-15 23:12:03 +01:00
parent 285f77a9e2
commit 599ee510cb
2 changed files with 20 additions and 1 deletions
+5 -1
View File
@@ -339,8 +339,12 @@ impl HostDescriptor for ActorFs<'_> {
HostDescriptor::rename_at(&mut self.inner, fd, old_path, new_fd, new_path).await?;
// Open writes and directories below a renamed folder move with it.
if let Some((from, to)) = moved {
// `join("")` would add a trailing slash, so a renamed file itself
// needs its own case.
let rebase = |p: &mut PathBuf| {
if let Ok(rest) = p.strip_prefix(&from) {
if *p == from {
*p = to.clone();
} else if let Ok(rest) = p.strip_prefix(&from) {
*p = to.join(rest);
}
};