aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/dir_rename.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-19 23:59:46 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-19 23:59:46 -0800
commit1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5 (patch)
treee8b08130edd727e14b8e1608fdb7771aab0d5764 /weed/filesys/dir_rename.go
parent2f15e9346696d18032b9d2bfffe459635cb36171 (diff)
downloadseaweedfs-1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5.tar.xz
seaweedfs-1b0bfbaf59ba613ebae6b90021b2270b3ac34bc5.zip
refactoring
Diffstat (limited to 'weed/filesys/dir_rename.go')
-rw-r--r--weed/filesys/dir_rename.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go
index 8309b238a..6b68e4ee9 100644
--- a/weed/filesys/dir_rename.go
+++ b/weed/filesys/dir_rename.go
@@ -2,7 +2,6 @@ package filesys
import (
"context"
- "fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
@@ -16,7 +15,10 @@ 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)
- err := dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {
+ 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 {
request := &filer_pb.AtomicRenameEntryRequest{
OldDirectory: dir.Path,
@@ -27,19 +29,11 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
_, err := client.AtomicRenameEntry(ctx, request)
if err != nil {
- return fmt.Errorf("renaming %s/%s => %s/%s: %v", dir.Path, req.OldName, newDir.Path, req.NewName, err)
+ glog.V(0).Infof("dir Rename %s/%s => %s/%s : %v", dir.Path, req.OldName, newDir.Path, req.NewName, err)
+ return fuse.EIO
}
return nil
})
-
- 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
}