Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pass the share to the cache instead of having to ask the storage
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Sep 5, 2023
commit 828ebd9c766e8f61abaf3d166b8b24f138b63d9a
16 changes: 12 additions & 4 deletions apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\Files\StorageNotAvailableException;
use OCP\ICacheFactory;
use OCP\IUserManager;
use OCP\Share\IShare;

/**
* Metadata cache for shared files
Expand All @@ -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,
Expand Down Expand Up @@ -150,7 +158,7 @@ protected function formatCacheEntry($entry, $path = null) {

try {
if (isset($entry['permissions'])) {
$entry['permissions'] &= $this->storage->getShare()->getPermissions();
$entry['permissions'] &= $this->share->getPermissions();
} else {
$entry['permissions'] = $this->storage->getPermissions($entry['path']);
}
Expand All @@ -159,7 +167,7 @@ protected function formatCacheEntry($entry, $path = null) {
// (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;
Expand All @@ -169,7 +177,7 @@ protected function formatCacheEntry($entry, $path = null) {

private function getOwnerDisplayName() {
if (!$this->ownerDisplayName) {
$uid = $this->storage->getOwner('');
$uid = $this->share->getShareOwner();
$this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid) ?? $uid;
}
return $this->ownerDisplayName;
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ public function getCache($path = '', $storage = null) {
$this->cache = new \OCA\Files_Sharing\Cache(
$storage,
$sourceRoot,
\OC::$server->get(DisplayNameCache::class)
\OC::$server->get(DisplayNameCache::class),
$this->getShare()
);
return $this->cache;
}
Expand Down