File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,9 @@ impl InodeTable {
165165 lookups = entry. lookups ;
166166 if lookups == 0 {
167167 delete = true ;
168- self . by_path . remove ( entry. path . as_ref ( ) . unwrap ( ) ) ;
168+ if let Some ( path) = entry. path . as_ref ( ) {
169+ self . by_path . remove ( path) ;
170+ }
169171 }
170172 }
171173
@@ -180,6 +182,12 @@ impl InodeTable {
180182 /// Change an inode's path to a different one, without changing the inode number.
181183 /// Lookup counts remain unchanged, even if this is replacing another file.
182184 pub fn rename ( & mut self , oldpath : & Path , newpath : Arc < PathBuf > ) {
185+ // unlink the new path from the previous inode holding it
186+ // otherwise, when kernel signals to forget the replaced inode, the path is removed from the by_path table
187+ if let Some ( dst) = self . by_path . remove ( Pathish :: new ( & newpath) ) {
188+ self . table [ dst] . path = None ;
189+ }
190+
183191 let idx = self . by_path . remove ( Pathish :: new ( oldpath) ) . unwrap ( ) ;
184192 self . table [ idx] . path = Some ( newpath. clone ( ) ) ;
185193 self . by_path . insert ( newpath, idx) ; // this can replace a path with a new inode
You can’t perform that action at this time.
0 commit comments