Skip to content

Commit 22ed863

Browse files
committed
Use DI for files_sharing Cache
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent e2042fb commit 22ed863

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

apps/files_sharing/lib/Cache.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,23 @@
4242
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
4343
*/
4444
class Cache extends CacheJail {
45-
/**
46-
* @var \OCA\Files_Sharing\SharedStorage
47-
*/
45+
/** @var \OCA\Files_Sharing\SharedStorage */
4846
private $storage;
49-
50-
/**
51-
* @var ICacheEntry
52-
*/
47+
/** @var ICacheEntry */
5348
private $sourceRootInfo;
49+
/** @var IUserManager */
50+
private $userManager;
5451

5552
private $rootUnchanged = true;
5653

5754
private $ownerDisplayName;
5855

5956
private $numericId;
6057

61-
/**
62-
* @param \OCA\Files_Sharing\SharedStorage $storage
63-
* @param ICacheEntry $sourceRootInfo
64-
*/
65-
public function __construct($storage, ICacheEntry $sourceRootInfo) {
58+
public function __construct(SharedStorage $storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) {
6659
$this->storage = $storage;
6760
$this->sourceRootInfo = $sourceRootInfo;
61+
$this->userManager = $userManager;
6862
$this->numericId = $sourceRootInfo->getStorageId();
6963

7064
parent::__construct(
@@ -172,7 +166,7 @@ protected function formatCacheEntry($entry, $path = null) {
172166
private function getOwnerDisplayName() {
173167
if (!$this->ownerDisplayName) {
174168
$uid = $this->storage->getOwner('');
175-
$user = \OC::$server->get(IUserManager::class)->get($uid);
169+
$user = $this->userManager->get($uid);
176170
if ($user) {
177171
$this->ownerDisplayName = $user->getDisplayName();
178172
} else {

apps/files_sharing/lib/SharedStorage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OCP\Files\NotFoundException;
4545
use OCP\Files\Storage\IDisableEncryptionStorage;
4646
use OCP\Files\Storage\IStorage;
47+
use OCP\IUserManager;
4748
use OCP\Lock\ILockingProvider;
4849
use OCP\Share\IShare;
4950

@@ -386,7 +387,11 @@ public function getCache($path = '', $storage = null) {
386387
return new FailedCache();
387388
}
388389

389-
$this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare);
390+
$this->cache = new \OCA\Files_Sharing\Cache(
391+
$storage,
392+
$sourceRoot,
393+
\OC::$server->get(IUserManager::class)
394+
);
390395
return $this->cache;
391396
}
392397

0 commit comments

Comments
 (0)