]> source.dussan.org Git - nextcloud-server.git/commitdiff
pass the share to the cache instead of having to ask the storage 41071/head
authorRobin Appelman <robin@icewind.nl>
Thu, 17 Aug 2023 17:43:32 +0000 (19:43 +0200)
committerJulius Härtl <jus@bitgrid.net>
Thu, 7 Dec 2023 10:08:19 +0000 (11:08 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/lib/Cache.php
apps/files_sharing/lib/SharedStorage.php

index eee65886a7f1063bade00f378468451c27cda4ee..af8e722c609dc876b40528f91c77fb00013f7cd2 100644 (file)
@@ -41,6 +41,7 @@ use OCP\Files\Search\ISearchOperator;
 use OCP\Files\StorageNotAvailableException;
 use OCP\ICacheFactory;
 use OCP\IUserManager;
+use OCP\Share\IShare;
 
 /**
  * Metadata cache for shared files
@@ -55,15 +56,22 @@ class Cache extends CacheJail {
        private ?string $ownerDisplayName = null;
        private $numericId;
        private DisplayNameCache $displayNameCache;
+       private IShare $share;
 
        /**
         * @param SharedStorage $storage
         */
-       public function __construct($storage, ICacheEntry $sourceRootInfo, DisplayNameCache $displayNameCache) {
+       public function __construct(
+               $storage,
+               ICacheEntry $sourceRootInfo,
+               DisplayNameCache $displayNameCache,
+               IShare $share
+       ) {
                $this->storage = $storage;
                $this->sourceRootInfo = $sourceRootInfo;
                $this->numericId = $sourceRootInfo->getStorageId();
                $this->displayNameCache = $displayNameCache;
+               $this->share = $share;
 
                parent::__construct(
                        null,
@@ -150,7 +158,7 @@ class Cache extends CacheJail {
 
                try {
                        if (isset($entry['permissions'])) {
-                               $entry['permissions'] &= $this->storage->getShare()->getPermissions();
+                               $entry['permissions'] &= $this->share->getPermissions();
                        } else {
                                $entry['permissions'] = $this->storage->getPermissions($entry['path']);
                        }
@@ -163,7 +171,7 @@ class Cache extends CacheJail {
                        // (IDE may say the exception is never thrown – false negative)
                        $sharePermissions = 0;
                }
-               $entry['uid_owner'] = $this->storage->getOwner('');
+               $entry['uid_owner'] = $this->share->getShareOwner();
                $entry['displayname_owner'] = $this->getOwnerDisplayName();
                if ($path === '') {
                        $entry['is_share_mount_point'] = true;
@@ -173,7 +181,7 @@ class Cache extends CacheJail {
 
        private function getOwnerDisplayName() {
                if (!$this->ownerDisplayName) {
-                       $uid = $this->storage->getOwner('');
+                       $uid = $this->share->getShareOwner();
                        $this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid) ?? $uid;
                }
                return $this->ownerDisplayName;
index 2c1ddf9af4ab70624b2612f80523452431822a2c..9eaa849a7e31a101f2f52058457664179aa3a2b2 100644 (file)
@@ -415,7 +415,8 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
                $this->cache = new \OCA\Files_Sharing\Cache(
                        $storage,
                        $sourceRoot,
-                       \OC::$server->get(DisplayNameCache::class)
+                       \OC::$server->get(DisplayNameCache::class),
+                       $this->getShare()
                );
                return $this->cache;
        }