mirror of
https://github.com/versity/versitygw.git
synced 2026-09-27 10:24:20 +00:00
fix: return better error when trying to delete non empty directory object
The posix backend will return ENOTEMPTY when trying to delete a directory that is not empty. This normally would run successfully on object systems. So we need to create another non-standard error for this case. We mainly just don't want to return InternalError for this case. Fixes #946
This commit is contained in:
@@ -519,6 +519,7 @@ func TestPosix(s *S3Conf) {
|
||||
PutObject_name_too_long(s)
|
||||
HeadObject_name_too_long(s)
|
||||
DeleteObject_name_too_long(s)
|
||||
DeleteObject_directory_not_empty(s)
|
||||
// posix specific versioning tests
|
||||
if !s.versioningEnabled {
|
||||
TestVersioningDisabled(s)
|
||||
@@ -770,6 +771,7 @@ func GetIntTests() IntTests {
|
||||
"ListObjectVersions_VD_success": ListObjectVersions_VD_success,
|
||||
"DeleteObject_non_existing_object": DeleteObject_non_existing_object,
|
||||
"DeleteObject_directory_object_noslash": DeleteObject_directory_object_noslash,
|
||||
"DeleteObject_directory_not_empty": DeleteObject_directory_not_empty,
|
||||
"DeleteObject_name_too_long": DeleteObject_name_too_long,
|
||||
"DeleteObject_non_existing_dir_object": DeleteObject_non_existing_dir_object,
|
||||
"DeleteObject_success": DeleteObject_success,
|
||||
|
||||
@@ -4749,6 +4749,37 @@ func DeleteObject_directory_object_noslash(s *S3Conf) error {
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteObject_directory_not_empty(s *S3Conf) error {
|
||||
testName := "DeleteObject_directory_not_empty"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
obj := "dir/my-obj"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err := s3client.PutObject(ctx, &s3.PutObjectInput{
|
||||
Bucket: &bucket,
|
||||
Key: &obj,
|
||||
})
|
||||
cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
obj = "dir/"
|
||||
ctx, cancel = context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err = s3client.DeleteObject(ctx, &s3.DeleteObjectInput{
|
||||
Bucket: &bucket,
|
||||
Key: &obj,
|
||||
})
|
||||
cancel()
|
||||
// object servers will return no error, but the posix backend returns
|
||||
// a non-standard directory not empty. This test is a posix only test
|
||||
// to validate the specific error response.
|
||||
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrDirectoryNotEmpty)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteObject_non_existing_dir_object(s *S3Conf) error {
|
||||
testName := "DeleteObject_non_existing_dir_object"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
|
||||
Reference in New Issue
Block a user