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
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-01-22 19:55:04 +0400
committerBjoern Schiessle <schiessle@owncloud.com>2014-01-23 16:36:33 +0400
commit2e8418b362ba0f1c35b83da16013142491f6760c (patch)
tree487d5d5b0a9b878a2e41af0932baa8adbab44711 /apps/files_encryption
parent1a938912229b9c67c29da1670735aa507f2e958e (diff)
fix infinite loop if folder and subfolder has the same name
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/lib/util.php52
1 files changed, 13 insertions, 39 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 8e1928aae9a..d011e677a41 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -2,9 +2,10 @@
/**
* ownCloud
*
- * @author Sam Tuke, Frank Karlitschek
+ * @author Sam Tuke, Frank Karlitschek, Bjoern Schiessle
* @copyright 2012 Sam Tuke <samtuke@owncloud.com>,
- * Frank Karlitschek <frank@owncloud.org>
+ * Frank Karlitschek <frank@owncloud.org>,
+ * Bjoern Schiessle <schiessle@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -1376,59 +1377,32 @@ class Util {
}
}
-
/**
* @brief go recursively through a dir and collect all files and sub files.
* @param string $dir relative to the users files folder
* @return array with list of files relative to the users files folder
*/
public function getAllFiles($dir) {
-
$result = array();
+ $dirList = array($dir);
- $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
- $this->userFilesDir . '/' . $dir));
-
- // handling for re shared folders
- $pathSplit = explode('/', $dir);
-
- foreach ($content as $c) {
-
- $sharedPart = $pathSplit[sizeof($pathSplit) - 1];
- $targetPathSplit = array_reverse(explode('/', $c['path']));
-
- $path = '';
-
- // rebuild path
- foreach ($targetPathSplit as $pathPart) {
-
- if ($pathPart !== $sharedPart) {
-
- $path = '/' . $pathPart . $path;
+ while ($dirList) {
+ $dir = array_pop($dirList);
+ $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
+ $this->userFilesDir . '/' . $dir));
+ foreach ($content as $c) {
+ $usersPath = isset($c['usersPath']) ? $c['usersPath'] : $c['path'];
+ if ($c['type'] === 'dir') {
+ $dirList[] = substr($usersPath, strlen("files"));
} else {
-
- break;
-
+ $result[] = substr($usersPath, strlen("files"));
}
-
}
- $path = $dir . $path;
-
- if ($c['type'] === 'dir') {
-
- $result = array_merge($result, $this->getAllFiles($path));
-
- } else {
-
- $result[] = $path;
-
- }
}
return $result;
-
}
/**