mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring filer rm
This commit is contained in:
parent
03f852c799
commit
2ed6d8cca6
|
@ -38,7 +38,7 @@ func (s3a *S3ApiServer) mkdir(parentDirectoryPath string, dirName string) error
|
||||||
|
|
||||||
func (s3a *S3ApiServer) list(parentDirectoryPath string) (entries []*filer_pb.Entry, err error) {
|
func (s3a *S3ApiServer) list(parentDirectoryPath string) (entries []*filer_pb.Entry, err error) {
|
||||||
|
|
||||||
s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.ListEntriesRequest{
|
request := &filer_pb.ListEntriesRequest{
|
||||||
Directory: s3a.option.BucketsPath,
|
Directory: s3a.option.BucketsPath,
|
||||||
|
@ -58,3 +58,27 @@ func (s3a *S3ApiServer) list(parentDirectoryPath string) (entries []*filer_pb.En
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s3a *S3ApiServer) rm(parentDirectoryPath string, entryName string, isDirectory, isDeleteData, isRecursive bool) error {
|
||||||
|
|
||||||
|
return s3a.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
request := &filer_pb.DeleteEntryRequest{
|
||||||
|
Directory: parentDirectoryPath,
|
||||||
|
Name: entryName,
|
||||||
|
IsDirectory: isDirectory,
|
||||||
|
IsDeleteData: isDeleteData,
|
||||||
|
IsRecursive: isRecursive,
|
||||||
|
}
|
||||||
|
|
||||||
|
glog.V(1).Infof("delete entry %v/%v: %v", parentDirectoryPath, entryName, request)
|
||||||
|
if _, err := client.DeleteEntry(ctx, request); err != nil {
|
||||||
|
return fmt.Errorf("delete entry %s/%s: %v", parentDirectoryPath, entryName, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -86,23 +86,11 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque
|
||||||
return fmt.Errorf("delete collection %s: %v", bucket, err)
|
return fmt.Errorf("delete collection %s: %v", bucket, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete bucket metadata
|
|
||||||
request := &filer_pb.DeleteEntryRequest{
|
|
||||||
Directory: s3a.option.BucketsPath,
|
|
||||||
Name: bucket,
|
|
||||||
IsDirectory: true,
|
|
||||||
IsDeleteData: false,
|
|
||||||
IsRecursive: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
glog.V(1).Infof("delete bucket: %v", request)
|
|
||||||
if _, err := client.DeleteEntry(ctx, request); err != nil {
|
|
||||||
return fmt.Errorf("delete bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
err = s3a.rm(s3a.option.BucketsPath, bucket, true, false, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponse(w, ErrInternalError, r.URL)
|
writeErrorResponse(w, ErrInternalError, r.URL)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue