diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-30 13:04:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 13:04:15 +0200 |
commit | 21f558b12bdb985ec312ac8973f2be9c0d73f824 (patch) | |
tree | 5c09ea1a8ad508986e9152109955ea7c5c28a187 /lib | |
parent | b9f35a73151ef1bd42959d4b39268856deca2f0c (diff) | |
parent | cf935e33ae08f49fec42ec5bc9ceca2d8830ef4b (diff) | |
download | nextcloud-server-21f558b12bdb985ec312ac8973f2be9c0d73f824.tar.gz nextcloud-server-21f558b12bdb985ec312ac8973f2be9c0d73f824.zip |
Merge pull request #46379 from nextcloud/fix/folder-search-owner
fix: `OCP\Files\Node\Folder::search` was not setting the owner
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Node/Folder.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 7ae55d046b9..79daa63d7b3 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -12,6 +12,7 @@ use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchOrder; use OC\Files\Search\SearchQuery; use OC\Files\Utils\PathHelper; +use OC\User\LazyUser; use OCP\Files\Cache\ICacheEntry; use OCP\Files\FileInfo; use OCP\Files\Mount\IMountPoint; @@ -26,6 +27,9 @@ use OCP\Files\Search\ISearchQuery; use OCP\IUserManager; class Folder extends Node implements \OCP\Files\Folder { + + private ?IUserManager $userManager = null; + /** * Creates a Folder that represents a non-existing path * @@ -245,7 +249,26 @@ class Folder extends Node implements \OCP\Files\Folder { $cacheEntry['internalPath'] = $cacheEntry['path']; $cacheEntry['path'] = rtrim($appendRoot . $cacheEntry->getPath(), '/'); $subPath = $cacheEntry['path'] !== '' ? '/' . $cacheEntry['path'] : ''; - return new \OC\Files\FileInfo($this->path . $subPath, $mount->getStorage(), $cacheEntry['internalPath'], $cacheEntry, $mount); + $storage = $mount->getStorage(); + + $owner = null; + $ownerId = $storage->getOwner($cacheEntry['internalPath']); + if (!empty($ownerId)) { + // Cache the user manager (for performance) + if ($this->userManager === null) { + $this->userManager = \OCP\Server::get(IUserManager::class); + } + $owner = new LazyUser($ownerId, $this->userManager); + } + + return new \OC\Files\FileInfo( + $this->path . $subPath, + $storage, + $cacheEntry['internalPath'], + $cacheEntry, + $mount, + $owner, + ); } /** |