diff options
author | Robin Appelman <robin@icewind.nl> | 2022-04-22 16:29:52 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-04-22 17:02:37 +0200 |
commit | 7a6c724a8122fe51c4d912f399474596a6aea7d1 (patch) | |
tree | 5ac624530974bac8531ca560bcbe38b58e682b63 /lib/private/Files/View.php | |
parent | 9a76f06ecadf05ef1d26bd735df1bea0dfb15d59 (diff) | |
download | nextcloud-server-7a6c724a8122fe51c4d912f399474596a6aea7d1.tar.gz nextcloud-server-7a6c724a8122fe51c4d912f399474596a6aea7d1.zip |
Use a lazy user for the file owner when listing a directory
Only getUID and getDisplayName are called on the file owner objects anyway
and we can get this information often without DB request
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/View.php')
-rw-r--r-- | lib/private/Files/View.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 30dc5518be8..f7b91a4b233 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -49,6 +49,8 @@ namespace OC\Files; use Icewind\Streams\CallbackWrapper; use OC\Files\Mount\MoveableMount; use OC\Files\Storage\Storage; +use OC\User\DisplayNameCache; +use OC\User\LazyUser; use OC\User\User; use OCA\Files_Sharing\SharedMount; use OCP\Constants; @@ -102,6 +104,8 @@ class View { /** @var \OCP\ILogger */ private $logger; + private DisplayNameCache $displayNameCache; + /** * @param string $root * @throws \Exception If $root contains an invalid path @@ -118,6 +122,7 @@ class View { $this->lockingProvider = \OC::$server->getLockingProvider(); $this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); $this->userManager = \OC::$server->getUserManager(); + $this->displayNameCache = \OC::$server->get(DisplayNameCache::class); $this->logger = \OC::$server->getLogger(); } @@ -1312,15 +1317,10 @@ class View { /** * @param string $ownerId - * @return \OC\User\User + * @return IUser */ - private function getUserObjectForOwner($ownerId) { - $owner = $this->userManager->get($ownerId); - if ($owner instanceof IUser) { - return $owner; - } else { - return new User($ownerId, null, \OC::$server->getEventDispatcher()); - } + private function getUserObjectForOwner(string $ownerId) { + return new LazyUser($ownerId, $this->displayNameCache, $this->userManager); } /** |