use more efficient method to find mountpoint for path
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
76780e313c
commit
2aad504e93
|
@ -70,23 +70,23 @@ class Manager implements IMountManager {
|
||||||
*/
|
*/
|
||||||
public function find($path) {
|
public function find($path) {
|
||||||
\OC_Util::setupFS();
|
\OC_Util::setupFS();
|
||||||
$path = $this->formatPath($path);
|
$path = Filesystem::normalizePath($path);
|
||||||
if (isset($this->mounts[$path])) {
|
|
||||||
return $this->mounts[$path];
|
|
||||||
}
|
|
||||||
|
|
||||||
\OC_Hook::emit('OC_Filesystem', 'get_mountpoint', array('path' => $path));
|
$current = $path;
|
||||||
$foundMountPoint = '';
|
while(true) {
|
||||||
$mountPoints = array_keys($this->mounts);
|
$mountPoint = $current . '/';
|
||||||
foreach ($mountPoints as $mountpoint) {
|
if (isset($this->mounts[$mountPoint])) {
|
||||||
if (strpos($path, $mountpoint) === 0 and strlen($mountpoint) > strlen($foundMountPoint)) {
|
return $this->mounts[$mountPoint];
|
||||||
$foundMountPoint = $mountpoint;
|
}
|
||||||
|
|
||||||
|
if ($current === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = dirname($current);
|
||||||
|
if ($current === '.' || $current === '/') {
|
||||||
|
$current = '';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (isset($this->mounts[$foundMountPoint])) {
|
|
||||||
return $this->mounts[$foundMountPoint];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue