Use DI for files_sharing Cache
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
e2042fb562
commit
22ed863dd7
|
@ -42,15 +42,12 @@ use OCP\IUserManager;
|
||||||
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
|
* don't use this class directly if you need to get metadata, use \OC\Files\Filesystem::getFileInfo instead
|
||||||
*/
|
*/
|
||||||
class Cache extends CacheJail {
|
class Cache extends CacheJail {
|
||||||
/**
|
/** @var \OCA\Files_Sharing\SharedStorage */
|
||||||
* @var \OCA\Files_Sharing\SharedStorage
|
|
||||||
*/
|
|
||||||
private $storage;
|
private $storage;
|
||||||
|
/** @var ICacheEntry */
|
||||||
/**
|
|
||||||
* @var ICacheEntry
|
|
||||||
*/
|
|
||||||
private $sourceRootInfo;
|
private $sourceRootInfo;
|
||||||
|
/** @var IUserManager */
|
||||||
|
private $userManager;
|
||||||
|
|
||||||
private $rootUnchanged = true;
|
private $rootUnchanged = true;
|
||||||
|
|
||||||
|
@ -58,13 +55,10 @@ class Cache extends CacheJail {
|
||||||
|
|
||||||
private $numericId;
|
private $numericId;
|
||||||
|
|
||||||
/**
|
public function __construct(SharedStorage $storage, ICacheEntry $sourceRootInfo, IUserManager $userManager) {
|
||||||
* @param \OCA\Files_Sharing\SharedStorage $storage
|
|
||||||
* @param ICacheEntry $sourceRootInfo
|
|
||||||
*/
|
|
||||||
public function __construct($storage, ICacheEntry $sourceRootInfo) {
|
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
$this->sourceRootInfo = $sourceRootInfo;
|
$this->sourceRootInfo = $sourceRootInfo;
|
||||||
|
$this->userManager = $userManager;
|
||||||
$this->numericId = $sourceRootInfo->getStorageId();
|
$this->numericId = $sourceRootInfo->getStorageId();
|
||||||
|
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
|
@ -172,7 +166,7 @@ class Cache extends CacheJail {
|
||||||
private function getOwnerDisplayName() {
|
private function getOwnerDisplayName() {
|
||||||
if (!$this->ownerDisplayName) {
|
if (!$this->ownerDisplayName) {
|
||||||
$uid = $this->storage->getOwner('');
|
$uid = $this->storage->getOwner('');
|
||||||
$user = \OC::$server->get(IUserManager::class)->get($uid);
|
$user = $this->userManager->get($uid);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->ownerDisplayName = $user->getDisplayName();
|
$this->ownerDisplayName = $user->getDisplayName();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -44,6 +44,7 @@ use OCP\Files\Cache\ICacheEntry;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\Files\Storage\IDisableEncryptionStorage;
|
use OCP\Files\Storage\IDisableEncryptionStorage;
|
||||||
use OCP\Files\Storage\IStorage;
|
use OCP\Files\Storage\IStorage;
|
||||||
|
use OCP\IUserManager;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
use OCP\Share\IShare;
|
use OCP\Share\IShare;
|
||||||
|
|
||||||
|
@ -386,7 +387,11 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
|
||||||
return new FailedCache();
|
return new FailedCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache = new \OCA\Files_Sharing\Cache($storage, $sourceRoot, $this->superShare);
|
$this->cache = new \OCA\Files_Sharing\Cache(
|
||||||
|
$storage,
|
||||||
|
$sourceRoot,
|
||||||
|
\OC::$server->get(IUserManager::class)
|
||||||
|
);
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue