diff options
Diffstat (limited to 'lib/private/Files/ObjectStore/S3ConnectionTrait.php')
-rw-r--r-- | lib/private/Files/ObjectStore/S3ConnectionTrait.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 86c665aa5f6..c7191ba2858 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -40,6 +40,7 @@ use Aws\S3\Exception\S3Exception; use Aws\S3\S3Client; use GuzzleHttp\Promise; use GuzzleHttp\Promise\RejectedPromise; +use OCP\Files\StorageNotAvailableException; use OCP\ICertificateManager; use OCP\Server; use Psr\Log\LoggerInterface; @@ -155,12 +156,12 @@ trait S3ConnectionTrait { $logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', ['app' => 'objectstore']); } - + if ($this->params['verify_bucket_exists'] && !$this->connection->doesBucketExist($this->bucket)) { try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); if (!$this->connection::isBucketDnsCompatible($this->bucket)) { - throw new \Exception("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); + throw new StorageNotAvailableException("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); } $this->connection->createBucket(['Bucket' => $this->bucket]); $this->testTimeout(); @@ -170,17 +171,17 @@ trait S3ConnectionTrait { 'app' => 'objectstore', ]); if ($e->getAwsErrorCode() !== 'BucketAlreadyOwnedByYou') { - throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); + throw new StorageNotAvailableException('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); } } } - + // google cloud's s3 compatibility doesn't like the EncodingType parameter if (strpos($base_url, 'storage.googleapis.com')) { $this->connection->getHandlerList()->remove('s3.auto_encode'); } } catch (S3Exception $e) { - throw new \Exception('S3 service is unable to handle request: ' . $e->getMessage()); + throw new StorageNotAvailableException('S3 service is unable to handle request: ' . $e->getMessage()); } return $this->connection; |