aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/inode_to_path.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-06-20 13:15:02 -0700
committerchrislu <chris.lu@gmail.com>2022-06-20 13:15:02 -0700
commit76f26c4b99367e9f37b6bc769a8bb13f48c02f67 (patch)
tree1b7dc3e4bfed236a4c3c3b826051d1e00610c79e /weed/mount/inode_to_path.go
parent625fd16a2e5eb676e8c9eaa0268f78246c69b1ef (diff)
downloadseaweedfs-76f26c4b99367e9f37b6bc769a8bb13f48c02f67.tar.xz
seaweedfs-76f26c4b99367e9f37b6bc769a8bb13f48c02f67.zip
mount: delete target entry first during move
Diffstat (limited to 'weed/mount/inode_to_path.go')
-rw-r--r--weed/mount/inode_to_path.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go
index e465158e8..64cabfaf5 100644
--- a/weed/mount/inode_to_path.go
+++ b/weed/mount/inode_to_path.go
@@ -157,6 +157,10 @@ func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedIn
defer i.Unlock()
sourceInode, sourceFound := i.path2inode[sourcePath]
targetInode, targetFound := i.path2inode[targetPath]
+ if targetFound {
+ delete(i.inode2path, targetInode)
+ delete(i.path2inode, targetPath)
+ }
if sourceFound {
delete(i.path2inode, sourcePath)
i.path2inode[targetPath] = sourceInode
@@ -165,11 +169,14 @@ func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedIn
// so no need to worry about their source inodes
return
}
- i.inode2path[sourceInode].FullPath = targetPath
- if targetFound {
- delete(i.inode2path, targetInode)
+ if entry, entryFound := i.inode2path[sourceInode]; entryFound {
+ entry.FullPath = targetPath
+ entry.isChildrenCached = false
+ if !targetFound {
+ entry.nlookup++
+ }
} else {
- i.inode2path[sourceInode].nlookup++
+ glog.Errorf("MovePath %s to %s: sourceInode %s not found", sourcePath, targetPath, sourceInode)
}
return targetInode
}