[Pkg-owncloud-commits] [owncloud] 66/258: Fixes #8326: deletion of directories on S3
David Prévot
taffit at moszumanska.debian.org
Sat Oct 11 17:22:22 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 5ac620cb0438416d511651e9f088e117405c97d8
Author: Johan Björk <johanimon at gmail.com>
Date: Tue Jul 8 22:28:12 2014 +0200
Fixes #8326: deletion of directories on S3
---
apps/files_external/lib/amazons3.php | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index cfc9b51..5d9c4d8 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,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list