File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
const {
6
6
S3Client,
7
+ HeadBucketCommand,
7
8
CreateBucketCommand,
8
9
PutObjectCommand,
9
10
DeleteObjectCommand,
@@ -112,13 +113,18 @@ class S3Adapter {
112
113
}
113
114
114
115
try {
115
- await this . _s3Client . send ( new CreateBucketCommand ( { Bucket : this . _bucket } ) ) ;
116
+ await this . _s3Client . send ( new HeadBucketCommand ( { Bucket : this . _bucket } ) ) ;
116
117
this . _hasBucket = true ;
117
- } catch ( error ) {
118
- if ( error . name === 'BucketAlreadyExists' || error . name === 'BucketAlreadyOwnedByYou' ) {
118
+ } catch {
119
+ try {
120
+ await this . _s3Client . send ( new CreateBucketCommand ( { Bucket : this . _bucket } ) ) ;
119
121
this . _hasBucket = true ;
120
- } else {
121
- throw error ;
122
+ } catch ( error ) {
123
+ if ( error . name === 'BucketAlreadyExists' || error . name === 'BucketAlreadyOwnedByYou' ) {
124
+ this . _hasBucket = true ;
125
+ } else {
126
+ throw error ;
127
+ }
122
128
}
123
129
}
124
130
}
You can’t perform that action at this time.
0 commit comments