mount: fix problems found in issue 1182
fix https://github.com/chrislusf/seaweedfs/issues/1182 always use the non-duplicated fs.Node Forget() the fs.Node Rename will also use the right fs.Node Avoid using the same file handle for the same file
This commit is contained in:
@@ -15,10 +15,7 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
|
||||
newDir := newDirectory.(*Dir)
|
||||
glog.V(4).Infof("dir Rename %s/%s => %s/%s", dir.Path, req.OldName, newDir.Path, req.NewName)
|
||||
|
||||
dir.wfs.cacheDelete(filer2.NewFullPath(newDir.Path, req.NewName))
|
||||
dir.wfs.cacheDelete(filer2.NewFullPath(dir.Path, req.OldName))
|
||||
|
||||
return dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {
|
||||
err := dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {
|
||||
|
||||
request := &filer_pb.AtomicRenameEntryRequest{
|
||||
OldDirectory: dir.Path,
|
||||
@@ -36,4 +33,27 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
|
||||
return nil
|
||||
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
oldPath := filer2.NewFullPath(dir.Path, req.OldName)
|
||||
dir.wfs.cacheDelete(filer2.NewFullPath(newDir.Path, req.NewName))
|
||||
dir.wfs.cacheDelete(oldPath)
|
||||
|
||||
oldFileNode := dir.wfs.getNode(oldPath, func() fs.Node {
|
||||
return nil
|
||||
})
|
||||
newDirNode := dir.wfs.getNode(filer2.FullPath(dir.Path), func() fs.Node {
|
||||
return nil
|
||||
})
|
||||
if oldFileNode != nil {
|
||||
oldFile := oldFileNode.(*File)
|
||||
oldFile.Name = req.NewName
|
||||
if newDirNode != nil {
|
||||
oldFile.dir = newDirNode.(*Dir)
|
||||
}
|
||||
}
|
||||
dir.wfs.forgetNode(oldPath)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user