Lazy init shared storage

This commit is contained in:
Robin Appelman 2016-08-22 12:27:56 +02:00
parent 95570d607c
commit 3ed01e8459
1 changed files with 9 additions and 17 deletions

View File

@ -61,11 +61,6 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
*/ */
private $sourceRootInfo; private $sourceRootInfo;
/**
* @var IStorage
*/
private $sourceStorage;
/** @var string */ /** @var string */
private $user; private $user;
@ -83,13 +78,9 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
$this->user = $arguments['user']; $this->user = $arguments['user'];
Filesystem::initMountPoints($this->superShare->getShareOwner());
$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
list($storage, $internalPath) = $this->ownerView->resolvePath($sourcePath);
parent::__construct([ parent::__construct([
'storage' => $storage, 'storage' => null,
'root' => $internalPath, 'root' => null,
]); ]);
} }
@ -101,8 +92,8 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
try { try {
Filesystem::initMountPoints($this->superShare->getShareOwner()); Filesystem::initMountPoints($this->superShare->getShareOwner());
$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId()); $sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath); list($this->storage, $this->rootPath) = $this->ownerView->resolvePath($sourcePath);
$this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath); $this->sourceRootInfo = $this->storage->getCache()->get($this->rootPath);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e); $this->logger->logException($e);
} }
@ -302,13 +293,13 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
public function getCache($path = '', $storage = null) { public function getCache($path = '', $storage = null) {
$this->init(); $this->init();
if (is_null($this->sourceStorage)) { if (is_null($this->storage)) {
return new FailedCache(false); return new FailedCache(false);
} }
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return new \OCA\Files_Sharing\Cache($storage, $this->sourceStorage, $this->sourceRootInfo); return new \OCA\Files_Sharing\Cache($storage, $this->storage, $this->sourceRootInfo);
} }
public function getScanner($path = '', $storage = null) { public function getScanner($path = '', $storage = null) {
@ -408,8 +399,9 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
// shares do not participate in availability logic // shares do not participate in availability logic
} }
public function getSourceStorage() { public function getWrapperStorage() {
return $this->sourceStorage; $this->init();
return $this->storage;
} }
public function file_get_contents($path) { public function file_get_contents($path) {