From 65141d4864d200d01e9fcd7cfea6e2e8cc4b3521 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 6 Nov 2020 11:06:40 +0100 Subject: [PATCH] Allow config to specify the bucket exists In the 99% case the bucket is just always there. And if it is not the read/write will fail hard anyways. Esp on big instances the Objectstore is not always fast and this can save a few hundered ms of each request that acess the objectstore. In short it is adding 'verify_bucket_exists' => false To the S3 config part Signed-off-by: Roeland Jago Douma --- lib/private/Files/ObjectStore/S3ConnectionTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 467ae81c8a46d..c98c8a04cdffa 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -76,6 +76,7 @@ protected function parseParams($params) { if (!isset($params['port']) || $params['port'] === '') { $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; } + $params['verify_bucket_exists'] = empty($params['verify_bucket_exists']) ? true : $params['verify_bucket_exists']; $this->params = $params; } @@ -130,7 +131,7 @@ public function getConnection() { ['app' => 'objectstore']); } - if (!$this->connection->doesBucketExist($this->bucket)) { + if ($this->params['verify_bucket_exists'] && !$this->connection->doesBucketExist($this->bucket)) { $logger = \OC::$server->getLogger(); try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']);