mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
correctly recursively delete folders
This commit is contained in:
parent
fa3ded4134
commit
c81f1cda47
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
"github.com/karlseguin/ccache"
|
"github.com/karlseguin/ccache"
|
||||||
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Filer struct {
|
type Filer struct {
|
||||||
|
@ -141,7 +142,11 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDelet
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.IsDirectory() {
|
if entry.IsDirectory() {
|
||||||
entries, err := f.ListDirectoryEntries(p, "", false, 1)
|
limit := int(1)
|
||||||
|
if isRecursive {
|
||||||
|
limit = math.MaxInt32
|
||||||
|
}
|
||||||
|
entries, err := f.ListDirectoryEntries(p, "", false, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("list folder %s: %v", p, err)
|
return fmt.Errorf("list folder %s: %v", p, err)
|
||||||
}
|
}
|
||||||
|
@ -161,6 +166,10 @@ func (f *Filer) DeleteEntryMetaAndData(p FullPath, isRecursive bool, shouldDelet
|
||||||
f.deleteChunks(entry.Chunks)
|
f.deleteChunks(entry.Chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p == "/" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
glog.V(0).Infof("deleting entry %v", p)
|
||||||
return f.store.DeleteEntry(p)
|
return f.store.DeleteEntry(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue