summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/amazons3.php
diff options
context:
space:
mode:
authorJohan Björk <johanimon@gmail.com>2014-07-08 22:28:12 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-09-11 18:01:01 +0200
commit5ac620cb0438416d511651e9f088e117405c97d8 (patch)
tree89b0f3161700937250a0e2c8d962c051376e160e /apps/files_external/lib/amazons3.php
parente26a5ff715258a24c874f87c8fd16630e5decf96 (diff)
downloadnextcloud-server-5ac620cb0438416d511651e9f088e117405c97d8.tar.gz
nextcloud-server-5ac620cb0438416d511651e9f088e117405c97d8.zip
Fixes #8326: deletion of directories on S3
Diffstat (limited to 'apps/files_external/lib/amazons3.php')
-rw-r--r--apps/files_external/lib/amazons3.php29
1 files changed, 12 insertions, 17 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index cfc9b5145d3..5d9c4d858c6 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -191,26 +191,17 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return false;
}
- $dh = $this->opendir($path);
-
- if(is_resource($dh)) {
- while (($file = readdir($dh)) !== false) {
- if ($file === '.' || $file === '..') {
- continue;
- }
-
- if ($this->is_dir($path . '/' . $file)) {
- $this->rmdir($path . '/' . $file);
- } else {
- $this->unlink($path . '/' . $file);
- }
- }
- }
+ // Since there are no real directories on S3, we need
+ // to delete all objects prefixed with the path.
+ $objects = $this->connection->listObjects([
+ 'Bucket' => $this->bucket,
+ 'Prefix' => $path . '/'
+ ]);
try {
- $result = $this->connection->deleteObject(array(
+ $result = $this->connection->deleteObjects(array(
'Bucket' => $this->bucket,
- 'Key' => $path . '/'
+ 'Objects' => $objects['Contents']
));
$this->testTimeout();
} catch (S3Exception $e) {
@@ -311,6 +302,10 @@ class AmazonS3 extends \OC\Files\Storage\Common {
public function unlink($path) {
$path = $this->normalizePath($path);
+ if ( $this->is_dir($path) ) {
+ return $this->rmdir($path);
+ }
+
try {
$result = $this->connection->deleteObject(array(
'Bucket' => $this->bucket,