Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/SharedMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function getNumericStorageId() {

$query = $builder->select('storage')
->from('filecache')
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getShare()->getNodeId())));
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId())));

return $query->execute()->fetchColumn();
}
Expand Down
30 changes: 14 additions & 16 deletions apps/files_sharing/lib/sharedstorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
*/
private $sourceRootInfo;

/**
* @var IStorage
*/
private $sourceStorage;

/** @var string */
private $user;

Expand All @@ -83,13 +78,9 @@ public function __construct($arguments) {

$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,
]);
}

Expand All @@ -101,9 +92,11 @@ private function init() {
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->storage = new FailedStorage(['exception' => $e]);
$this->rootPath = '';
$this->logger->logException($e);
}
}
Expand Down Expand Up @@ -302,13 +295,13 @@ public function getItemType() {

public function getCache($path = '', $storage = null) {
$this->init();
if (is_null($this->sourceStorage)) {
if (is_null($this->storage) || $this->storage instanceof FailedStorage) {
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) {
Expand Down Expand Up @@ -409,7 +402,12 @@ public function setAvailability($available) {
}

public function getSourceStorage() {
return $this->sourceStorage;
return $this->getWrapperStorage();
}

public function getWrapperStorage() {
$this->init();
return $this->storage;
}

public function file_get_contents($path) {
Expand Down
18 changes: 10 additions & 8 deletions lib/private/Files/Mount/MountPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MountPoint implements IMountPoint {
*/
private $invalidStorage = false;

/** @var int|null */
/** @var int|null */
protected $mountId;

/**
Expand Down Expand Up @@ -132,31 +132,33 @@ public function setMountPoint($mountPoint) {

/**
* create the storage that is mounted
*
* @return \OC\Files\Storage\Storage
*/
private function createStorage() {
if ($this->invalidStorage) {
return null;
return;
}

if (class_exists($this->class)) {
try {
return $this->loader->getInstance($this, $this->class, $this->arguments);
$class = $this->class;
// prevent recursion by setting the storage before applying wrappers
$this->storage = new $class($this->arguments);
$this->storage = $this->loader->wrap($this, $this->storage);
} catch (\Exception $exception) {
$this->storage = null;
$this->invalidStorage = true;
if ($this->mountPoint === '/') {
// the root storage could not be initialized, show the user!
throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception);
} else {
\OCP\Util::writeLog('core', $exception->getMessage(), \OCP\Util::ERROR);
}
return null;
return;
}
} else {
\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR);
$this->invalidStorage = true;
return null;
return;
}
}

Expand All @@ -165,7 +167,7 @@ private function createStorage() {
*/
public function getStorage() {
if (is_null($this->storage)) {
$this->storage = $this->createStorage();
$this->createStorage();
}
return $this->storage;
}
Expand Down
Loading