Lazy init shared storage

This commit is contained in:
Robin Appelman 2016-08-22 12:27:56 +02:00
parent 89d4684ef1
commit f4e89c15bf
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;
/**
* @var IStorage
*/
private $sourceStorage;
/** @var string */
private $user;
@ -83,13 +78,9 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
$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([
'storage' => $storage,
'root' => $internalPath,
'storage' => null,
'root' => null,
]);
}
@ -101,8 +92,8 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
try {
Filesystem::initMountPoints($this->superShare->getShareOwner());
$sourcePath = $this->ownerView->getPath($this->superShare->getNodeId());
list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath);
$this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath);
list($this->storage, $this->rootPath) = $this->ownerView->resolvePath($sourcePath);
$this->sourceRootInfo = $this->storage->getCache()->get($this->rootPath);
} catch (\Exception $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) {
$this->init();
if (is_null($this->sourceStorage)) {
if (is_null($this->storage)) {
return new FailedCache(false);
}
if (!$storage) {
$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) {
@ -408,8 +399,9 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
// shares do not participate in availability logic
}
public function getSourceStorage() {
return $this->sourceStorage;
public function getWrapperStorage() {
$this->init();
return $this->storage;
}
public function file_get_contents($path) {