summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-08-01 14:04:21 +0200
committerRobin Appelman <icewind@owncloud.com>2014-08-01 14:04:21 +0200
commit4886c8582d1956b4958226f5da2c5fe8d6693ff9 (patch)
treecfd4ab73c0c20779db632d138422d2a2c2c62b0e
parent6cbfe8fd987d166ff26a7987c7e4983797ada78d (diff)
parentac75a245974593aee5c05b3d63998339e2ea2929 (diff)
downloadnextcloud-server-4886c8582d1956b4958226f5da2c5fe8d6693ff9.tar.gz
nextcloud-server-4886c8582d1956b4958226f5da2c5fe8d6693ff9.zip
Merge pull request #9529 from helmutschneider/fix-8326
Fixes #8326: deletion of directories on S3
-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 10fc626c5da..3b0ae5bbe0d 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -190,26 +190,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(array(
+ '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) {
@@ -310,6 +301,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,