From e64a10da00d0bdfcc91097c1e6fdeb479d1680d5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 3 Nov 2020 14:32:58 +0100 Subject: [PATCH] only filter submounts for fileinfo on demand this removes the need to always setup all the sub storages when getting a folder info Signed-off-by: Robin Appelman --- lib/private/Files/FileInfo.php | 23 +++++++++++++++-------- lib/private/Files/View.php | 7 ++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 8f42aff85bbcf..d32377fd1a8e5 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -33,6 +33,7 @@ namespace OC\Files; +use OCA\Files_Sharing\SharedStorage; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; use OCP\IUser; @@ -73,6 +74,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { */ private $childEtags = []; + private $includeShareSubMounts = true; + /** * @var IMountPoint[] */ @@ -162,7 +165,7 @@ public function getInternalPath() { * @return int|null */ public function getId() { - return isset($this->data['fileid']) ? (int) $this->data['fileid'] : null; + return isset($this->data['fileid']) ? (int)$this->data['fileid'] : null; } /** @@ -216,7 +219,7 @@ public function getSize($includeMounts = true) { */ public function getMTime() { $this->updateEntryfromSubMounts(); - return (int) $this->data['mtime']; + return (int)$this->data['mtime']; } /** @@ -232,18 +235,18 @@ public function isEncrypted() { * @return int */ public function getEncryptedVersion() { - return isset($this->data['encryptedVersion']) ? (int) $this->data['encryptedVersion'] : 1; + return isset($this->data['encryptedVersion']) ? (int)$this->data['encryptedVersion'] : 1; } /** * @return int */ public function getPermissions() { - $perms = (int) $this->data['permissions']; + $perms = (int)$this->data['permissions']; if (\OCP\Util::isSharingDisabledForUser() || ($this->isShared() && !\OC\Share\Share::isResharingAllowed())) { $perms = $perms & ~\OCP\Constants::PERMISSION_SHARE; } - return (int) $perms; + return (int)$perms; } /** @@ -352,6 +355,10 @@ public function getOwner() { return $this->owner; } + public function setIncludeShareSubMounts(bool $include) { + $this->includeShareSubMounts = $include; + } + /** * @param IMountPoint[] $mounts */ @@ -366,7 +373,7 @@ private function updateEntryfromSubMounts() { $this->subMountsUsed = true; foreach ($this->subMounts as $mount) { $subStorage = $mount->getStorage(); - if ($subStorage) { + if ($subStorage && ($this->includeShareSubMounts || !($subStorage instanceof SharedStorage))) { $subCache = $subStorage->getCache(''); $rootEntry = $subCache->get(''); $this->addSubEntry($rootEntry, $mount->getMountPoint()); @@ -408,10 +415,10 @@ public function getExtension(): string { } public function getCreationTime(): int { - return (int) $this->data['creation_time']; + return (int)$this->data['creation_time']; } public function getUploadTime(): int { - return (int) $this->data['upload_time']; + return (int)$this->data['upload_time']; } } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 16074a89ca83a..e765de8a70d1d 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1400,12 +1400,9 @@ public function getFileInfo($path, $includeMountPoints = true) { if ($data and isset($data['fileid'])) { if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') { //add the sizes of other mount points to the folder - $extOnly = ($includeMountPoints === 'ext'); + $info->setIncludeShareSubMounts($includeMountPoints !== 'ext'); $mounts = Filesystem::getMountManager()->findIn($path); - $info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) { - $subStorage = $mount->getStorage(); - return !($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage); - })); + $info->setSubMounts($mounts); } }