mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: delete target entry first during move
This commit is contained in:
parent
625fd16a2e
commit
76f26c4b99
|
@ -157,6 +157,10 @@ func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedIn
|
||||||
defer i.Unlock()
|
defer i.Unlock()
|
||||||
sourceInode, sourceFound := i.path2inode[sourcePath]
|
sourceInode, sourceFound := i.path2inode[sourcePath]
|
||||||
targetInode, targetFound := i.path2inode[targetPath]
|
targetInode, targetFound := i.path2inode[targetPath]
|
||||||
|
if targetFound {
|
||||||
|
delete(i.inode2path, targetInode)
|
||||||
|
delete(i.path2inode, targetPath)
|
||||||
|
}
|
||||||
if sourceFound {
|
if sourceFound {
|
||||||
delete(i.path2inode, sourcePath)
|
delete(i.path2inode, sourcePath)
|
||||||
i.path2inode[targetPath] = sourceInode
|
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
|
// so no need to worry about their source inodes
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
i.inode2path[sourceInode].FullPath = targetPath
|
if entry, entryFound := i.inode2path[sourceInode]; entryFound {
|
||||||
if targetFound {
|
entry.FullPath = targetPath
|
||||||
delete(i.inode2path, targetInode)
|
entry.isChildrenCached = false
|
||||||
|
if !targetFound {
|
||||||
|
entry.nlookup++
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
i.inode2path[sourceInode].nlookup++
|
glog.Errorf("MovePath %s to %s: sourceInode %s not found", sourcePath, targetPath, sourceInode)
|
||||||
}
|
}
|
||||||
return targetInode
|
return targetInode
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue