From a7f669044eed395ed9ca86c534c504e11af8d3e0 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 14 Aug 2020 00:22:49 -0700 Subject: [PATCH] rename also applies to open file handle --- weed/filesys/dir_rename.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index c2ff6f407..0e417e0ab 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -64,9 +64,16 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector // fmt.Printf("rename path: %v => %v\n", oldPath, newPath) dir.wfs.fsNodeCache.Move(oldPath, newPath) + // change file handle dir.wfs.handlesLock.Lock() defer dir.wfs.handlesLock.Unlock() - delete(dir.wfs.handles, oldPath.AsInode()) + inodeId := oldPath.AsInode() + existingHandle, found := dir.wfs.handles[inodeId] + if !found || existingHandle == nil { + return err + } + delete(dir.wfs.handles, inodeId) + dir.wfs.handles[newPath.AsInode()] = existingHandle return err }