mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3 test bucket delete nonempty
This commit is contained in:
parent
ce8ef60c59
commit
a8b15c676c
|
@ -148,6 +148,13 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
isEmpty, err := s3a.isDirectoryAllEmpty(client, s3a.option.BucketsPath, bucket)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("check empty bucket %s: %v", bucket, err)
|
||||||
|
}
|
||||||
|
if !isEmpty {
|
||||||
|
return fmt.Errorf("BucketNotEmpty")
|
||||||
|
}
|
||||||
|
|
||||||
// delete collection
|
// delete collection
|
||||||
deleteCollectionRequest := &filer_pb.DeleteCollectionRequest{
|
deleteCollectionRequest := &filer_pb.DeleteCollectionRequest{
|
||||||
|
@ -162,6 +169,15 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
s3ErrorCode := s3err.ErrInternalError
|
||||||
|
if err.Error() == "BucketNotEmpty" {
|
||||||
|
s3ErrorCode = s3err.ErrBucketNotEmpty
|
||||||
|
}
|
||||||
|
writeErrorResponse(w, s3ErrorCode, r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = s3a.rm(s3a.option.BucketsPath, bucket, false, true)
|
err = s3a.rm(s3a.option.BucketsPath, bucket, false, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue