Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-06 22:47:20 +0400
committerVincent Petry <pvince81@owncloud.com>2013-12-03 13:47:26 +0400
commit6eef3c9c4c95a97d7446dfc8dda81114e612abf7 (patch)
tree51f9ef22633894109139efca96421f9f130de0f8 /lib
parenta385e86e5822a3147c4dbf6fb30432ab91004b9f (diff)
Make rmdir recursive for local storage
Backport of 63c898c0
Diffstat (limited to 'lib')
-rw-r--r--lib/files/storage/local.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php
index f4d7626219b..a6fe01c63d6 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);