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:
+5
-1
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user