aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-08-28 13:44:03 +0200
committerGitHub <noreply@github.com>2023-08-28 13:44:03 +0200
commitd4e67afed77cd8b93f807816fe5be856bb1d6d6c (patch)
tree574783869c7876c91ff955a21ff960f67e48cb4f /apps/files_sharing/lib
parentce9e0aec7f9c56b95ccddaea316f00f936d3ad3b (diff)
parentdf71b4d7348cd9d287c626fa0e11a00e1745897c (diff)
downloadnextcloud-server-d4e67afed77cd8b93f807816fe5be856bb1d6d6c.tar.gz
nextcloud-server-d4e67afed77cd8b93f807816fe5be856bb1d6d6c.zip
Merge pull request #39944 from nextcloud/share-cache-share
pass the share to the cache instead of having to ask the storage
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Cache.php16
-rw-r--r--apps/files_sharing/lib/SharedStorage.php3
2 files changed, 14 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index b99a511312e..594660661ca 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -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']);
}
@@ -159,7 +167,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;
@@ -169,7 +177,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;
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 759394f22e6..c56bcaebb12 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -413,7 +413,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;
}