@@ -155,25 +155,25 @@ public function getConnection() {
155155 $ cacheKey = $ this ->params ['hostname ' ] . $ this ->bucket ;
156156 $ exist = $ this ->existingBucketsCache ->get ($ cacheKey ) === 1 ;
157157
158- if (!$ exist && !$ this ->connection ->doesBucketExist ($ this ->bucket )) {
159- try {
160- $ logger ->info ('Bucket " ' . $ this ->bucket . '" does not exist - creating it. ' , ['app ' => 'objectstore ' ]);
161- if (!$ this ->connection ::isBucketDnsCompatible ($ this ->bucket )) {
162- throw new StorageNotAvailableException ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
163- }
164- $ this ->connection ->createBucket (['Bucket ' => $ this ->bucket ]);
165- $ this ->testTimeout ();
166- $ this ->existingBucketsCache ->set ($ cacheKey , 1 );
167- } catch (S3Exception $ e ) {
168- $ logger ->debug ('Invalid remote storage. ' , [
169- 'exception ' => $ e ,
170- 'app ' => 'objectstore ' ,
171- ]);
172- if ($ e ->getAwsErrorCode () !== 'BucketAlreadyOwnedByYou ' ) {
173- throw new StorageNotAvailableException ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
158+ if (!$ exist ) {
159+ if (!$ this ->connection ->doesBucketExist ($ this ->bucket )) {
160+ try {
161+ $ logger ->info ('Bucket " ' . $ this ->bucket . '" does not exist - creating it. ' , ['app ' => 'objectstore ' ]);
162+ if (!$ this ->connection ::isBucketDnsCompatible ($ this ->bucket )) {
163+ throw new StorageNotAvailableException ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
164+ }
165+ $ this ->connection ->createBucket (['Bucket ' => $ this ->bucket ]);
166+ $ this ->testTimeout ();
167+ } catch (S3Exception $ e ) {
168+ $ logger ->debug ('Invalid remote storage. ' , [
169+ 'exception ' => $ e ,
170+ 'app ' => 'objectstore ' ,
171+ ]);
172+ if ($ e ->getAwsErrorCode () !== 'BucketAlreadyOwnedByYou ' ) {
173+ throw new StorageNotAvailableException ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
174+ }
174175 }
175176 }
176- } elseif (!$ exist ) {
177177 $ this ->existingBucketsCache ->set ($ cacheKey , 1 );
178178 }
179179 }
0 commit comments