Skip to content

Commit

Permalink
fix bug in rename
Browse files Browse the repository at this point in the history
  • Loading branch information
YangKeao committed Jan 15, 2021
1 parent af92440 commit ba17837
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hookfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl InodeMap {
.insert(path.as_ref().to_owned());
}

fn remove_path<P: AsRef<Path>>(&mut self, inode: &u64, path: P) {
fn remove_path<P: AsRef<Path>>(&mut self, inode: u64, path: P) {
match self.0.get_mut(&inode) {
Some(set) => {
set.remove(path.as_ref());
Expand Down Expand Up @@ -541,7 +541,7 @@ impl AsyncFileSystemImpl for HookFs {

let stat = self.get_file_attr(&path).await?;
trace!("remove {} from inode_map", &stat.ino);
self.inode_map.write().await.remove_path(&stat.ino, &path);
self.inode_map.write().await.remove_path(stat.ino, &path);

trace!("unlinking {}", path.display());
async_unlink(&path).await?;
Expand Down Expand Up @@ -617,11 +617,13 @@ impl AsyncFileSystemImpl for HookFs {
trace!("rename from {} to {}", path.display(), new_path.display());

let new_path_clone = new_path.clone();
spawn_blocking(move || renameat(None, &path, None, &new_path_clone)).await??;
let path_clone = path.clone();
spawn_blocking(move || renameat(None, &path_clone, None, &new_path_clone)).await??;

let stat = self.get_file_attr(&new_path).await?;

trace!("insert ({}, {})", stat.ino, new_path.display());
inode_map.remove_path(stat.ino, &path);
inode_map.insert_path(stat.ino, new_path);

Ok(())
Expand Down

0 comments on commit ba17837

Please sign in to comment.