[Pkg-owncloud-commits] [owncloud] 51/83: Make rmdir recursive for local storage
David Prévot
taffit at moszumanska.debian.org
Wed Dec 18 13:05:30 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch 5.0
in repository owncloud.
commit 6eef3c9c4c95a97d7446dfc8dda81114e612abf7
Author: Robin Appelman <icewind at owncloud.com>
Date: Thu Jun 6 20:47:20 2013 +0200
Make rmdir recursive for local storage
Backport of 63c898c0
---
lib/files/storage/local.php | 22 +++++++++++++++++++++-
tests/lib/files/storage/storage.php | 2 +-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php
index f4d7626..a6fe01c 100644
--- a/lib/files/storage/local.php
+++ b/lib/files/storage/local.php
@@ -34,7 +34,27 @@ class Local extends \OC\Files\Storage\Common{
return @mkdir($this->datadir.$path);
}
public function rmdir($path) {
- return @rmdir($this->datadir.$path);
+ try {
+ $it = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($this->datadir . $path),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+ foreach ($it as $file) {
+ /**
+ * @var \SplFileInfo $file
+ */
+ if (in_array($file->getBasename(), array('.', '..'))) {
+ continue;
+ } elseif ($file->isDir()) {
+ rmdir($file->getPathname());
+ } elseif ($file->isFile() || $file->isLink()) {
+ unlink($file->getPathname());
+ }
+ }
+ return rmdir($this->datadir . $path);
+ } catch (\UnexpectedValueException $e) {
+ return false;
+ }
}
public function opendir($path) {
return opendir($this->datadir.$path);
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index ea3ca7d..9ee49f8 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -281,7 +281,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertEquals(file_get_contents($textFile), $content);
}
- public function testTouchCreateFile(){
+ public function testTouchCreateFile() {
$this->assertFalse($this->instance->file_exists('foo'));
$this->instance->touch('foo');
$this->assertTrue($this->instance->file_exists('foo'));
--
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