aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/dir_rename.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-19 12:31:56 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-19 12:31:56 -0800
commit2f15e9346696d18032b9d2bfffe459635cb36171 (patch)
tree3236719ecbdcb9c1ed6f1e84eff86aa5ccf374ce /weed/filesys/dir_rename.go
parent04019aa161dcfe04511da41e198c9d3b5b1b66dc (diff)
downloadseaweedfs-2f15e9346696d18032b9d2bfffe459635cb36171.tar.xz
seaweedfs-2f15e9346696d18032b9d2bfffe459635cb36171.zip
mount: rename also clear the cache
fix https://github.com/chrislusf/seaweedfs/issues/1182
Diffstat (limited to 'weed/filesys/dir_rename.go')
-rw-r--r--weed/filesys/dir_rename.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go
index 7890d24d9..8309b238a 100644
--- a/weed/filesys/dir_rename.go
+++ b/weed/filesys/dir_rename.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/fuse"
@@ -15,7 +16,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)
- 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,
@@ -33,4 +34,12 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
})
+ if err == nil {
+ oldpath := string(filer2.NewFullPath(dir.Path, req.OldName))
+ newpath := string(filer2.NewFullPath(newDir.Path, req.NewName))
+ dir.wfs.listDirectoryEntriesCache.Delete(oldpath)
+ dir.wfs.listDirectoryEntriesCache.Delete(newpath)
+ }
+
+ return err
}