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 <robin@icewind.nl>2018-08-16 19:53:32 +0300
committerRobin Appelman <robin@icewind.nl>2018-08-27 17:21:20 +0300
commitbb092553efa3131123eab27b8631e56995986a22 (patch)
treeae5925bba75983740a3566b3ef080b1bfdc8fb2a /lib
parent67ae310693f6457bdbbdfe414e2ed5eae23f1124 (diff)
use more efficient method to find mountpoint for path
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Mount/Manager.php31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php
index 7bd888a6389..e479a7d2a86 100644
--- a/lib/private/Files/Mount/Manager.php
+++ b/lib/private/Files/Mount/Manager.php
@@ -70,23 +70,24 @@ class Manager implements IMountManager {
*/
public function find($path) {
\OC_Util::setupFS();
- $path = $this->formatPath($path);
- if (isset($this->mounts[$path])) {
- return $this->mounts[$path];
- }
+ $path = Filesystem::normalizePath($path);
- \OC_Hook::emit('OC_Filesystem', 'get_mountpoint', array('path' => $path));
- $foundMountPoint = '';
- $mountPoints = array_keys($this->mounts);
- foreach ($mountPoints as $mountpoint) {
- if (strpos($path, $mountpoint) === 0 and strlen($mountpoint) > strlen($foundMountPoint)) {
- $foundMountPoint = $mountpoint;
+ $current = $path;
+ while(true) {
+ $mountPoint = $current . '/';
+ if (isset($this->mounts[$mountPoint])) {
+ $this->pathCache[$path] = $this->mounts[$mountPoint];
+ return $this->mounts[$mountPoint];
+ }
+
+ if ($current === '') {
+ return null;
+ }
+
+ $current = dirname($current);
+ if ($current === '.' || $current === '/') {
+ $current = '';
}
- }
- if (isset($this->mounts[$foundMountPoint])) {
- return $this->mounts[$foundMountPoint];
- } else {
- return null;
}
}