fix(S3): use doesBucketExist() to evaluate bucket existance

This commit is contained in:
Manuel Jenny 2021-04-29 13:04:41 +02:00
parent 2f1f9faeae
commit c55dc62d16
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18

View File

@ -110,16 +110,9 @@ class S3Impl {
} }
public boolean bucketExists() throws BackendException { public boolean bucketExists() throws BackendException {
try { if (client().doesBucketExist(cloud.s3Bucket())) {
client().listObjectsV2(cloud.s3Bucket());
} catch(AmazonS3Exception ex) {
if (ex.getErrorCode().equals(S3CloudApiExceptions.S3CloudApiErrorCodes.NO_SUCH_BUCKET.getValue())) {
throw new NoSuchBucketException(cloud.s3Bucket()); throw new NoSuchBucketException(cloud.s3Bucket());
} else {
throw new FatalBackendException(ex);
} }
}
return true; return true;
} }