diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-07-19 01:21:44 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-07-19 01:21:44 -0700 |
| commit | c7228fefa70ef4f88d66484f4ac362b1be2d5a5c (patch) | |
| tree | 87a09312e3e7207aa42282b022fa3fdf8dea205b /weed/filer2/filer.go | |
| parent | 702fbdf7310aa266bc0854492a83589d663d803e (diff) | |
| download | seaweedfs-c7228fefa70ef4f88d66484f4ac362b1be2d5a5c.tar.xz seaweedfs-c7228fefa70ef4f88d66484f4ac362b1be2d5a5c.zip | |
add bucket creation and deletion
1. option for "weed s3 -filer.dir.buckets" to choose a folder for buckets
2. create a bucket
3. delete a bucket, recursively delete all metadata on filer
Diffstat (limited to 'weed/filer2/filer.go')
| -rw-r--r-- | weed/filer2/filer.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index a98194bc8..2ecf3976e 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -125,7 +125,7 @@ func (f *Filer) FindEntry(p FullPath) (entry *Entry, err error) { return f.store.FindEntry(p) } -func (f *Filer) DeleteEntryMetaAndData(p FullPath, shouldDeleteChunks bool) (err error) { +func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDeleteChunks bool) (err error) { entry, err := f.FindEntry(p) if err != nil { return err @@ -136,8 +136,14 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, shouldDeleteChunks bool) (err if err != nil { return fmt.Errorf("list folder %s: %v", p, err) } - if len(entries) > 0 { - return fmt.Errorf("folder %s is not empty", p) + if isRecursive { + for _, sub := range entries { + f.DeleteEntryMetaAndData(sub.FullPath, isRecursive, shouldDeleteChunks) + } + } else { + if len(entries) > 0 { + return fmt.Errorf("folder %s is not empty", p) + } } f.cacheDelDirectory(string(p)) } @@ -158,7 +164,7 @@ func (f *Filer) ListDirectoryEntries(p FullPath, startFileName string, inclusive func (f *Filer) cacheDelDirectory(dirpath string) { if f.directoryCache == nil { - return + return } f.directoryCache.Delete(dirpath) return |
