mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 01:00:50 -04:00
Merge pull request #31946 from nextcloud/s3-versioning-not-implemented-23
[23] AmazonS3: allow not implemented versioning
This commit is contained in:
commit
c8e1143328
1 changed files with 14 additions and 2 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue