Skip to content

Commit b6d0274

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

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

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(
@@ -168,7 +162,7 @@ protected function formatCacheEntry($entry, $path = null) {
168162
private function getOwnerDisplayName() {
169163
if (!$this->ownerDisplayName) {
170164
$uid = $this->storage->getOwner('');
171-
$user = \OC::$server->get(IUserManager::class)->get($uid);
165+
$user = $this->userManager->get($uid);
172166
if ($user) {
173167
$this->ownerDisplayName = $user->getDisplayName();
174168
} else {

apps/files_sharing/lib/SharedStorage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OCP\Files\NotFoundException;
4444
use OCP\Files\Storage\IDisableEncryptionStorage;
4545
use OCP\Files\Storage\IStorage;
46+
use OCP\IUserManager;
4647
use OCP\Lock\ILockingProvider;
4748

4849
/**
@@ -384,7 +385,11 @@ public function getCache($path = '', $storage = null) {
384385
return new FailedCache();
385386
}
386387

387-
$this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare);
388+
$this->cache = new \OCA\Fwiles_Sharing\Cache(
389+
$storage,
390+
$sourceRoot,
391+
\OC::$server->get(IUserManager::class)
392+
);
388393
return $this->cache;
389394
}
390395

0 commit comments

Comments
 (0)