Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik van Velzen <erik@evanv.nl>2022-03-09 12:35:24 +0300
committerErik van Velzen <erik@evanv.nl>2022-03-15 02:40:38 +0300
commit17f3e5e4b5e18d641087c9c2be6924506d802a66 (patch)
tree3c60c6499e047d06959483499ff7834847b11f99 /apps/files_external
parentbf75b1d5c5be4adca1fec4a259e45dfa3ad1a8a6 (diff)
AmazonS3: allow not implemented versioning
In case the S3 implementation does not implement versioning, set it to false. Versioning was introduced in Nexcloud in commit 09ffac5e6dd5355c9aaf49c098942fa1e4fbed25 This is needed for compatibility with the Storj gateway. Signed-off-by: Erik van Velzen <erik@evanv.nl>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php16
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)) {