diff options
author | Louis <6653109+artonge@users.noreply.github.com> | 2022-03-15 10:26:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-15 10:26:43 +0100 |
commit | 1ae6b2be71acecca486ce24f61a713ad6a669fc8 (patch) | |
tree | 2c5ada1a13e1330997fa3ace9326519bc97ce50e | |
parent | 246964072589a26df742f5ea2c33e4951a0c9887 (diff) | |
parent | 17f3e5e4b5e18d641087c9c2be6924506d802a66 (diff) | |
download | nextcloud-server-1ae6b2be71acecca486ce24f61a713ad6a669fc8.tar.gz nextcloud-server-1ae6b2be71acecca486ce24f61a713ad6a669fc8.zip |
Merge pull request #31498 from Erikvv/s3-versioning-not-implemented
AmazonS3: allow not implemented versioning
-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)) { |