summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-10-11 13:45:02 +0200
committerVincent Petry <vincent@nextcloud.com>2021-10-11 13:45:02 +0200
commit09ab7a40fefea254df69217e11bf7cbfb60777e0 (patch)
tree8ef767655d360b84de07e1ed2f97e1d18cf8fd01 /apps/files_external
parent4a1a9d6821fa61885080793ab34cdb9f4d2d0057 (diff)
downloadnextcloud-server-09ab7a40fefea254df69217e11bf7cbfb60777e0.tar.gz
nextcloud-server-09ab7a40fefea254df69217e11bf7cbfb60777e0.zip
Delete S3 versions in rmdir
When deleting a complete folder in a bucket that has versioning enabled, also make sure to delete all associated versions and delete markers Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 1bdd11e39bd..a6872f1dc3e 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -311,13 +311,35 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$connection->deleteObjects([
'Bucket' => $this->bucket,
'Delete' => [
- 'Objects' => $objects['Contents']
+ 'Objects' => $objects['Contents'],
]
]);
$this->testTimeout();
}
// we reached the end when the list is no longer truncated
} while ($objects['IsTruncated']);
+
+ do {
+ // delete all contained versions and deletion markers
+ $objects = $connection->listObjectVersions($params);
+ if (isset($objects['Versions'])) {
+ $connection->deleteObjects([
+ 'Bucket' => $this->bucket,
+ 'Delete' => [
+ 'Objects' => $objects['Versions'],
+ ]
+ ]);
+ }
+ if (isset($objects['DeleteMarkers'])) {
+ $connection->deleteObjects([
+ 'Bucket' => $this->bucket,
+ 'Delete' => [
+ 'Objects' => $objects['DeleteMarkers'],
+ ]
+ ]);
+ }
+ // we reached the end when the list is no longer truncated
+ } while ($objects['IsTruncated']);
$this->deleteObject($path);
} catch (S3Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files_external']);