diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-05-16 13:46:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 13:46:13 +0300 |
commit | 8c61f1941b42444d245120382b46f486a1805f09 (patch) | |
tree | bd8100313ff5450671b2a95bc2a5b8afbc188cec /apps | |
parent | 16fd38439ef6f4402c37655e342d3af638c9c4aa (diff) | |
parent | 25e8efc04d2ded8524c0534e0ea6390087b1ba57 (diff) |
Merge pull request #32015 from nextcloud/backport/31946/stable22
[stable22] AmazonS3: allow not implemented versioning
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/AmazonS3.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 2c01a803840..cfd78689fa4 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -732,8 +732,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { if ($this->versioningEnabled === null) { $cached = $this->memCache->get('versioning-enabled::' . $this->getBucket()); if ($cached === null) { - $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]); - $this->versioningEnabled = $result->get('Status') === 'Enabled'; + $this->versioningEnabled = $this->getVersioningStatusFromBucket(); $this->memCache->set('versioning-enabled::' . $this->getBucket(), $this->versioningEnabled, 60); } else { $this->versioningEnabled = $cached; @@ -742,6 +741,19 @@ class AmazonS3 extends \OC\Files\Storage\Common { return $this->versioningEnabled; } + protected function getVersioningStatusFromBucket(): bool { + try { + $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]); + return $result->get('Status') === 'Enabled'; + } catch (S3Exception $s3Exception) { + // This is needed for compatibility with Storj gateway which does not support versioning yet + if ($s3Exception->getAwsErrorCode() === 'NotImplemented') { + return false; + } + throw $s3Exception; + } + } + public function hasUpdated($path, $time) { // for files we can get the proper mtime if ($path !== '' && $object = $this->headObject($path)) { |