diff options
author | Johan Björk <johanimon@gmail.com> | 2014-07-08 22:28:12 +0200 |
---|---|---|
committer | Johan Björk <johanimon@gmail.com> | 2014-07-08 22:41:11 +0200 |
commit | e44a7aa034c0340254c3e5d68c1e949d106d4f46 (patch) | |
tree | 938bc09df967f3044105c8615532f6986bead8f8 /apps/files_external/lib/amazons3.php | |
parent | 87adbf1c6e24402dc29b4166bfdac919303803ce (diff) | |
download | nextcloud-server-e44a7aa034c0340254c3e5d68c1e949d106d4f46.tar.gz nextcloud-server-e44a7aa034c0340254c3e5d68c1e949d106d4f46.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.php | 29 |
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..909d3f6b8ef 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([ + '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, |