diff options
author | S. Cat <33800996+sparrowjack63@users.noreply.github.com> | 2019-02-26 09:32:14 +0100 |
---|---|---|
committer | Sébastien Cat <sebastien.cat@inra.fr> | 2019-03-01 11:28:54 +0100 |
commit | 77473b0228d52ab7add4f0c469631cbb2a9171ba (patch) | |
tree | 1bcdc474b9a4db77d85bdf8fd2843a47a7225fa6 /lib/private/Files | |
parent | 59c3d8d85f77c1176099ddfd3d37086608a0d39d (diff) | |
download | nextcloud-server-77473b0228d52ab7add4f0c469631cbb2a9171ba.tar.gz nextcloud-server-77473b0228d52ab7add4f0c469631cbb2a9171ba.zip |
Warning on S3 not compatible DNS bucket name
The new created bucket should respect the DNS compatibility, nevertheless, Nextcloud should accept to mount "old created" buckets that does not respect DNS compatibility (Backward compatibility, or compatibility with CEPH).
Signed-off-by: Sébastien Cat <sebastien.cat@inra.fr>
Diffstat (limited to 'lib/private/Files')
-rw-r--r-- | lib/private/Files/ObjectStore/S3ConnectionTrait.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 02b6fff6846..4bb98e11490 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -99,13 +99,20 @@ trait S3ConnectionTrait { } $this->connection = new S3Client($options); - if (!$this->connection->doesBucketExist($this->bucket)) { + if (!$this->connection->isBucketDnsCompatible($this->bucket)) { + $logger = \OC::$server->getLogger(); + $logger->warning('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', + ['app' => 'objectstore']); + } + + if (!$this->connection->doesBucketExist($this->bucket)) { $logger = \OC::$server->getLogger(); try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); - $this->connection->createBucket(array( - 'Bucket' => $this->bucket - )); + 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); + } + $this->connection->createBucket(array('Bucket' => $this->bucket)); $this->testTimeout(); } catch (S3Exception $e) { $logger->logException($e, [ |