13
13
use Aws \S3 \S3Client ;
14
14
use GuzzleHttp \Promise \Create ;
15
15
use GuzzleHttp \Promise \RejectedPromise ;
16
+ use OCP \Files \StorageNotAvailableException ;
16
17
use OCP \ICertificateManager ;
17
18
use OCP \Server ;
18
19
use Psr \Log \LoggerInterface ;
@@ -132,7 +133,7 @@ public function getConnection() {
132
133
try {
133
134
$ logger ->info ('Bucket " ' . $ this ->bucket . '" does not exist - creating it. ' , ['app ' => 'objectstore ' ]);
134
135
if (!$ this ->connection ::isBucketDnsCompatible ($ this ->bucket )) {
135
- throw new \ Exception ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
136
+ throw new StorageNotAvailableException ('The bucket will not be created because the name is not dns compatible, please correct it: ' . $ this ->bucket );
136
137
}
137
138
$ this ->connection ->createBucket (['Bucket ' => $ this ->bucket ]);
138
139
$ this ->testTimeout ();
@@ -142,17 +143,17 @@ public function getConnection() {
142
143
'app ' => 'objectstore ' ,
143
144
]);
144
145
if ($ e ->getAwsErrorCode () !== 'BucketAlreadyOwnedByYou ' ) {
145
- throw new \ Exception ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
146
+ throw new StorageNotAvailableException ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
146
147
}
147
148
}
148
149
}
149
-
150
+
150
151
// google cloud's s3 compatibility doesn't like the EncodingType parameter
151
152
if (strpos ($ base_url , 'storage.googleapis.com ' )) {
152
153
$ this ->connection ->getHandlerList ()->remove ('s3.auto_encode ' );
153
154
}
154
155
} catch (S3Exception $ e ) {
155
- throw new \ Exception ('S3 service is unable to handle request: ' . $ e ->getMessage ());
156
+ throw new StorageNotAvailableException ('S3 service is unable to handle request: ' . $ e ->getMessage ());
156
157
}
157
158
158
159
return $ this ->connection ;
0 commit comments