diff options
| author | chrislu <chris.lu@gmail.com> | 2022-02-13 01:43:11 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-02-13 01:43:11 -0800 |
| commit | 813b868b9ad8d22e05acc3f2003a9c196cdd83b5 (patch) | |
| tree | fd49599cd96eb6d405b69cba64b2942614ac9b41 | |
| parent | e85ca10a1a426e9808024f65dd0921b241296796 (diff) | |
| download | seaweedfs-813b868b9ad8d22e05acc3f2003a9c196cdd83b5.tar.xz seaweedfs-813b868b9ad8d22e05acc3f2003a9c196cdd83b5.zip | |
add rmdir
| -rw-r--r-- | weed/mount/weedfs_dir_mkrm.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.go index 670275915..69bafaa7e 100644 --- a/weed/mount/weedfs_dir_mkrm.go +++ b/weed/mount/weedfs_dir_mkrm.go @@ -8,6 +8,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/hanwen/go-fuse/v2/fuse" "os" + "strings" + "syscall" "time" ) @@ -70,3 +72,32 @@ func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out return fuse.OK } + +func (wfs *WFS) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) { + + if name == "." { + return fuse.Status(syscall.EINVAL) + } + if name == ".." { + return fuse.Status(syscall.ENOTEMPTY) + } + + dirFullPath := wfs.inodeToPath.GetPath(header.NodeId) + entryFullPath := dirFullPath.Child(name) + + glog.V(3).Infof("remove directory: %v", entryFullPath) + ignoreRecursiveErr := true // ignore recursion error since the OS should manage it + err := filer_pb.Remove(wfs, string(dirFullPath), name, true, true, ignoreRecursiveErr, false, []int32{wfs.signature}) + if err != nil { + glog.V(0).Infof("remove %s: %v", entryFullPath, err) + if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) { + return fuse.Status(syscall.ENOTEMPTY) + } + return fuse.ENOENT + } + + wfs.metaCache.DeleteEntry(context.Background(), entryFullPath) + + return fuse.OK + +} |
