summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Mount
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-26 19:53:10 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-04 12:44:56 +0200
commit37233471b6698f798c9f0b9bf0286c4d9c342204 (patch)
treef4734f6024bdb55dd50b1ff2606fc8eb9c77ce02 /lib/private/Files/Mount
parent6868da9958f25bbf0212d1cd2d5d918152e50d78 (diff)
downloadnextcloud-server-37233471b6698f798c9f0b9bf0286c4d9c342204.tar.gz
nextcloud-server-37233471b6698f798c9f0b9bf0286c4d9c342204.zip
Add pathcache
* If we find the mountpoint for a path cache it * If we modify the mount points empty the pathCache Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files/Mount')
-rw-r--r--lib/private/Files/Mount/Manager.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php
index d98d45ae0b7..f27dfaacc8b 100644
--- a/lib/private/Files/Mount/Manager.php
+++ b/lib/private/Files/Mount/Manager.php
@@ -26,21 +26,28 @@ declare(strict_types=1);
namespace OC\Files\Mount;
-use \OC\Files\Filesystem;
+use OC\Cache\CappedMemoryCache;
+use OC\Files\Filesystem;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
class Manager implements IMountManager {
- /**
- * @var MountPoint[]
- */
+ /** @var MountPoint[] */
private $mounts = [];
+ /** @var CappedMemoryCache */
+ private $pathCache;
+
+ public function __construct() {
+ $this->pathCache = new CappedMemoryCache();
+ }
+
/**
* @param IMountPoint $mount
*/
public function addMount(IMountPoint $mount) {
$this->mounts[$mount->getMountPoint()] = $mount;
+ $this->pathCache->clear();
}
/**
@@ -52,6 +59,7 @@ class Manager implements IMountManager {
$mountPoint .= '/';
}
unset($this->mounts[$mountPoint]);
+ $this->pathCache->clear();
}
/**
@@ -61,6 +69,7 @@ class Manager implements IMountManager {
public function moveMount(string $mountPoint, string $target){
$this->mounts[$target] = $this->mounts[$mountPoint];
unset($this->mounts[$mountPoint]);
+ $this->pathCache->clear();
}
/**
@@ -76,6 +85,10 @@ class Manager implements IMountManager {
return $this->mounts[$path];
}
+ if (isset($this->pathCache[$path])) {
+ return $this->pathCache[$path];
+ }
+
\OC_Hook::emit('OC_Filesystem', 'get_mountpoint', ['path' => $path]);
$foundMountPoint = '';
$mountPoints = array_keys($this->mounts);
@@ -88,6 +101,7 @@ class Manager implements IMountManager {
}
if (isset($this->mounts[$foundMountPoint])) {
+ $this->pathCache[$path] = $this->mounts[$foundMountPoint];
return $this->mounts[$foundMountPoint];
}
@@ -116,6 +130,7 @@ class Manager implements IMountManager {
public function clear() {
$this->mounts = [];
+ $this->pathCache->clear();
}
/**