|
|
|
@ -38,8 +38,12 @@ class Manager implements IMountManager { |
|
|
|
/** @var CappedMemoryCache */ |
|
|
|
private $pathCache; |
|
|
|
|
|
|
|
/** @var CappedMemoryCache */ |
|
|
|
private $inPathCache; |
|
|
|
|
|
|
|
public function __construct() { |
|
|
|
$this->pathCache = new CappedMemoryCache(); |
|
|
|
$this->inPathCache = new CappedMemoryCache(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -48,6 +52,7 @@ class Manager implements IMountManager { |
|
|
|
public function addMount(IMountPoint $mount) { |
|
|
|
$this->mounts[$mount->getMountPoint()] = $mount; |
|
|
|
$this->pathCache->clear(); |
|
|
|
$this->inPathCache->clear(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -60,16 +65,18 @@ class Manager implements IMountManager { |
|
|
|
} |
|
|
|
unset($this->mounts[$mountPoint]); |
|
|
|
$this->pathCache->clear(); |
|
|
|
$this->inPathCache->clear(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param string $mountPoint |
|
|
|
* @param string $target |
|
|
|
*/ |
|
|
|
public function moveMount(string $mountPoint, string $target){ |
|
|
|
public function moveMount(string $mountPoint, string $target) { |
|
|
|
$this->mounts[$target] = $this->mounts[$mountPoint]; |
|
|
|
unset($this->mounts[$mountPoint]); |
|
|
|
$this->pathCache->clear(); |
|
|
|
$this->inPathCache->clear(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -87,7 +94,7 @@ class Manager implements IMountManager { |
|
|
|
} |
|
|
|
|
|
|
|
$current = $path; |
|
|
|
while(true) { |
|
|
|
while (true) { |
|
|
|
$mountPoint = $current . '/'; |
|
|
|
if (isset($this->mounts[$mountPoint])) { |
|
|
|
$this->pathCache[$path] = $this->mounts[$mountPoint]; |
|
|
|
@ -114,6 +121,11 @@ class Manager implements IMountManager { |
|
|
|
public function findIn(string $path): array { |
|
|
|
\OC_Util::setupFS(); |
|
|
|
$path = $this->formatPath($path); |
|
|
|
|
|
|
|
if (isset($this->inPathCache[$path])) { |
|
|
|
return $this->inPathCache[$path]; |
|
|
|
} |
|
|
|
|
|
|
|
$result = []; |
|
|
|
$pathLength = \strlen($path); |
|
|
|
$mountPoints = array_keys($this->mounts); |
|
|
|
@ -122,12 +134,15 @@ class Manager implements IMountManager { |
|
|
|
$result[] = $this->mounts[$mountPoint]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$this->inPathCache[$path] = $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
|
|
|
|
public function clear() { |
|
|
|
$this->mounts = []; |
|
|
|
$this->pathCache->clear(); |
|
|
|
$this->inPathCache->clear(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|