diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-05-13 23:56:16 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-05-13 23:56:16 -0700 |
| commit | c5cf9bd29046877ed6b173e5d2723f865d06aa66 (patch) | |
| tree | 4e5aeb06f0f319aeb29135b44581e31dd80b662a /weed/filer2/filer.go | |
| parent | f01d5616b3dba0779d2adbe361271a8f9626e8ee (diff) | |
| download | seaweedfs-c5cf9bd29046877ed6b173e5d2723f865d06aa66.tar.xz seaweedfs-c5cf9bd29046877ed6b173e5d2723f865d06aa66.zip | |
properly working filer
Diffstat (limited to 'weed/filer2/filer.go')
| -rw-r--r-- | weed/filer2/filer.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index ad7a3d906..5f76d6fb0 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -114,11 +114,24 @@ func (f *Filer) FindEntry(p FullPath) (found bool, entry *Entry, err error) { } func (f *Filer) DeleteEntry(p FullPath) (fileEntry *Entry, err error) { + found, entry, err := f.FindEntry(p) + if err != nil || !found { + return nil, err + } + if entry.IsDirectory() { + entries, err := f.ListDirectoryEntries(p, "", false, 1) + if err != nil { + return nil, fmt.Errorf("list folder %s: %v", p, err) + } + if len(entries) > 0 { + return nil, fmt.Errorf("folder %s is not empty", p) + } + } return f.store.DeleteEntry(p) } func (f *Filer) ListDirectoryEntries(p FullPath, startFileName string, inclusive bool, limit int) ([]*Entry, error) { - if strings.HasSuffix(string(p), "/") { + if strings.HasSuffix(string(p), "/") && len(p) > 1 { p = p[0:len(p)-1] } return f.store.ListDirectoryEntries(p, startFileName, inclusive, limit) |
