Merge pull request #1008 from nextcloud/shared-storage-non-recursive-10

[10] Fix shared storage recursive setup
This commit is contained in:
Lukas Reschke 2016-08-23 22:15:21 +02:00 committed by GitHub
commit 805fc22276
6 changed files with 125 additions and 125 deletions

View File

@ -244,7 +244,7 @@ class SharedMount extends MountPoint implements MoveableMount {
$query = $builder->select('storage') $query = $builder->select('storage')
->from('filecache') ->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(); return $query->execute()->fetchColumn();
} }

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,9 +92,11 @@ 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->storage = new FailedStorage(['exception' => $e]);
$this->rootPath = '';
$this->logger->logException($e); $this->logger->logException($e);
} }
} }
@ -302,13 +295,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) || $this->storage instanceof FailedStorage) {
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) {
@ -409,7 +402,12 @@ class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
} }
public function getSourceStorage() { public function getSourceStorage() {
return $this->sourceStorage; return $this->getWrapperStorage();
}
public function getWrapperStorage() {
$this->init();
return $this->storage;
} }
public function file_get_contents($path) { public function file_get_contents($path) {

View File

@ -132,18 +132,20 @@ class MountPoint implements IMountPoint {
/** /**
* create the storage that is mounted * create the storage that is mounted
*
* @return \OC\Files\Storage\Storage
*/ */
private function createStorage() { private function createStorage() {
if ($this->invalidStorage) { if ($this->invalidStorage) {
return null; return;
} }
if (class_exists($this->class)) { if (class_exists($this->class)) {
try { 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) { } catch (\Exception $exception) {
$this->storage = null;
$this->invalidStorage = true; $this->invalidStorage = true;
if ($this->mountPoint === '/') { if ($this->mountPoint === '/') {
// the root storage could not be initialized, show the user! // the root storage could not be initialized, show the user!
@ -151,12 +153,12 @@ class MountPoint implements IMountPoint {
} else { } else {
\OCP\Util::writeLog('core', $exception->getMessage(), \OCP\Util::ERROR); \OCP\Util::writeLog('core', $exception->getMessage(), \OCP\Util::ERROR);
} }
return null; return;
} }
} else { } else {
\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR); \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR);
$this->invalidStorage = true; $this->invalidStorage = true;
return null; return;
} }
} }
@ -165,7 +167,7 @@ class MountPoint implements IMountPoint {
*/ */
public function getStorage() { public function getStorage() {
if (is_null($this->storage)) { if (is_null($this->storage)) {
$this->storage = $this->createStorage(); $this->createStorage();
} }
return $this->storage; return $this->storage;
} }

View File

@ -68,7 +68,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function mkdir($path) { public function mkdir($path) {
return $this->storage->mkdir($this->getSourcePath($path)); return $this->getWrapperStorage()->mkdir($this->getSourcePath($path));
} }
/** /**
@ -78,7 +78,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function rmdir($path) { public function rmdir($path) {
return $this->storage->rmdir($this->getSourcePath($path)); return $this->getWrapperStorage()->rmdir($this->getSourcePath($path));
} }
/** /**
@ -88,7 +88,7 @@ class Jail extends Wrapper {
* @return resource * @return resource
*/ */
public function opendir($path) { public function opendir($path) {
return $this->storage->opendir($this->getSourcePath($path)); return $this->getWrapperStorage()->opendir($this->getSourcePath($path));
} }
/** /**
@ -98,7 +98,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function is_dir($path) { public function is_dir($path) {
return $this->storage->is_dir($this->getSourcePath($path)); return $this->getWrapperStorage()->is_dir($this->getSourcePath($path));
} }
/** /**
@ -108,7 +108,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function is_file($path) { public function is_file($path) {
return $this->storage->is_file($this->getSourcePath($path)); return $this->getWrapperStorage()->is_file($this->getSourcePath($path));
} }
/** /**
@ -119,7 +119,7 @@ class Jail extends Wrapper {
* @return array * @return array
*/ */
public function stat($path) { public function stat($path) {
return $this->storage->stat($this->getSourcePath($path)); return $this->getWrapperStorage()->stat($this->getSourcePath($path));
} }
/** /**
@ -129,7 +129,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function filetype($path) { public function filetype($path) {
return $this->storage->filetype($this->getSourcePath($path)); return $this->getWrapperStorage()->filetype($this->getSourcePath($path));
} }
/** /**
@ -140,7 +140,7 @@ class Jail extends Wrapper {
* @return int * @return int
*/ */
public function filesize($path) { public function filesize($path) {
return $this->storage->filesize($this->getSourcePath($path)); return $this->getWrapperStorage()->filesize($this->getSourcePath($path));
} }
/** /**
@ -150,7 +150,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function isCreatable($path) { public function isCreatable($path) {
return $this->storage->isCreatable($this->getSourcePath($path)); return $this->getWrapperStorage()->isCreatable($this->getSourcePath($path));
} }
/** /**
@ -160,7 +160,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function isReadable($path) { public function isReadable($path) {
return $this->storage->isReadable($this->getSourcePath($path)); return $this->getWrapperStorage()->isReadable($this->getSourcePath($path));
} }
/** /**
@ -170,7 +170,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function isUpdatable($path) { public function isUpdatable($path) {
return $this->storage->isUpdatable($this->getSourcePath($path)); return $this->getWrapperStorage()->isUpdatable($this->getSourcePath($path));
} }
/** /**
@ -180,7 +180,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function isDeletable($path) { public function isDeletable($path) {
return $this->storage->isDeletable($this->getSourcePath($path)); return $this->getWrapperStorage()->isDeletable($this->getSourcePath($path));
} }
/** /**
@ -190,7 +190,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function isSharable($path) { public function isSharable($path) {
return $this->storage->isSharable($this->getSourcePath($path)); return $this->getWrapperStorage()->isSharable($this->getSourcePath($path));
} }
/** /**
@ -201,7 +201,7 @@ class Jail extends Wrapper {
* @return int * @return int
*/ */
public function getPermissions($path) { public function getPermissions($path) {
return $this->storage->getPermissions($this->getSourcePath($path)); return $this->getWrapperStorage()->getPermissions($this->getSourcePath($path));
} }
/** /**
@ -211,7 +211,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function file_exists($path) { public function file_exists($path) {
return $this->storage->file_exists($this->getSourcePath($path)); return $this->getWrapperStorage()->file_exists($this->getSourcePath($path));
} }
/** /**
@ -221,7 +221,7 @@ class Jail extends Wrapper {
* @return int * @return int
*/ */
public function filemtime($path) { public function filemtime($path) {
return $this->storage->filemtime($this->getSourcePath($path)); return $this->getWrapperStorage()->filemtime($this->getSourcePath($path));
} }
/** /**
@ -231,7 +231,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function file_get_contents($path) { public function file_get_contents($path) {
return $this->storage->file_get_contents($this->getSourcePath($path)); return $this->getWrapperStorage()->file_get_contents($this->getSourcePath($path));
} }
/** /**
@ -242,7 +242,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function file_put_contents($path, $data) { public function file_put_contents($path, $data) {
return $this->storage->file_put_contents($this->getSourcePath($path), $data); return $this->getWrapperStorage()->file_put_contents($this->getSourcePath($path), $data);
} }
/** /**
@ -252,7 +252,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function unlink($path) { public function unlink($path) {
return $this->storage->unlink($this->getSourcePath($path)); return $this->getWrapperStorage()->unlink($this->getSourcePath($path));
} }
/** /**
@ -263,7 +263,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function rename($path1, $path2) { public function rename($path1, $path2) {
return $this->storage->rename($this->getSourcePath($path1), $this->getSourcePath($path2)); return $this->getWrapperStorage()->rename($this->getSourcePath($path1), $this->getSourcePath($path2));
} }
/** /**
@ -274,7 +274,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function copy($path1, $path2) { public function copy($path1, $path2) {
return $this->storage->copy($this->getSourcePath($path1), $this->getSourcePath($path2)); return $this->getWrapperStorage()->copy($this->getSourcePath($path1), $this->getSourcePath($path2));
} }
/** /**
@ -285,7 +285,7 @@ class Jail extends Wrapper {
* @return resource * @return resource
*/ */
public function fopen($path, $mode) { public function fopen($path, $mode) {
return $this->storage->fopen($this->getSourcePath($path), $mode); return $this->getWrapperStorage()->fopen($this->getSourcePath($path), $mode);
} }
/** /**
@ -296,7 +296,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function getMimeType($path) { public function getMimeType($path) {
return $this->storage->getMimeType($this->getSourcePath($path)); return $this->getWrapperStorage()->getMimeType($this->getSourcePath($path));
} }
/** /**
@ -308,7 +308,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function hash($type, $path, $raw = false) { public function hash($type, $path, $raw = false) {
return $this->storage->hash($type, $this->getSourcePath($path), $raw); return $this->getWrapperStorage()->hash($type, $this->getSourcePath($path), $raw);
} }
/** /**
@ -318,7 +318,7 @@ class Jail extends Wrapper {
* @return int * @return int
*/ */
public function free_space($path) { public function free_space($path) {
return $this->storage->free_space($this->getSourcePath($path)); return $this->getWrapperStorage()->free_space($this->getSourcePath($path));
} }
/** /**
@ -328,7 +328,7 @@ class Jail extends Wrapper {
* @return array * @return array
*/ */
public function search($query) { public function search($query) {
return $this->storage->search($query); return $this->getWrapperStorage()->search($query);
} }
/** /**
@ -340,7 +340,7 @@ class Jail extends Wrapper {
* @return bool * @return bool
*/ */
public function touch($path, $mtime = null) { public function touch($path, $mtime = null) {
return $this->storage->touch($this->getSourcePath($path), $mtime); return $this->getWrapperStorage()->touch($this->getSourcePath($path), $mtime);
} }
/** /**
@ -351,7 +351,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function getLocalFile($path) { public function getLocalFile($path) {
return $this->storage->getLocalFile($this->getSourcePath($path)); return $this->getWrapperStorage()->getLocalFile($this->getSourcePath($path));
} }
/** /**
@ -365,7 +365,7 @@ class Jail extends Wrapper {
* returning true for other changes in the folder is optional * returning true for other changes in the folder is optional
*/ */
public function hasUpdated($path, $time) { public function hasUpdated($path, $time) {
return $this->storage->hasUpdated($this->getSourcePath($path), $time); return $this->getWrapperStorage()->hasUpdated($this->getSourcePath($path), $time);
} }
/** /**
@ -377,9 +377,9 @@ class Jail extends Wrapper {
*/ */
public function getCache($path = '', $storage = null) { public function getCache($path = '', $storage = null) {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this->getWrapperStorage();
} }
$sourceCache = $this->storage->getCache($this->getSourcePath($path), $storage); $sourceCache = $this->getWrapperStorage()->getCache($this->getSourcePath($path), $storage);
return new CacheJail($sourceCache, $this->rootPath); return new CacheJail($sourceCache, $this->rootPath);
} }
@ -390,7 +390,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function getOwner($path) { public function getOwner($path) {
return $this->storage->getOwner($this->getSourcePath($path)); return $this->getWrapperStorage()->getOwner($this->getSourcePath($path));
} }
/** /**
@ -404,7 +404,7 @@ class Jail extends Wrapper {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getWatcher($this->getSourcePath($path), $storage); return $this->getWrapperStorage()->getWatcher($this->getSourcePath($path), $storage);
} }
/** /**
@ -414,7 +414,7 @@ class Jail extends Wrapper {
* @return string * @return string
*/ */
public function getETag($path) { public function getETag($path) {
return $this->storage->getETag($this->getSourcePath($path)); return $this->getWrapperStorage()->getETag($this->getSourcePath($path));
} }
/** /**
@ -422,7 +422,7 @@ class Jail extends Wrapper {
* @return array * @return array
*/ */
public function getMetaData($path) { public function getMetaData($path) {
return $this->storage->getMetaData($this->getSourcePath($path)); return $this->getWrapperStorage()->getMetaData($this->getSourcePath($path));
} }
/** /**
@ -432,7 +432,7 @@ class Jail extends Wrapper {
* @throws \OCP\Lock\LockedException * @throws \OCP\Lock\LockedException
*/ */
public function acquireLock($path, $type, ILockingProvider $provider) { public function acquireLock($path, $type, ILockingProvider $provider) {
$this->storage->acquireLock($this->getSourcePath($path), $type, $provider); $this->getWrapperStorage()->acquireLock($this->getSourcePath($path), $type, $provider);
} }
/** /**
@ -441,7 +441,7 @@ class Jail extends Wrapper {
* @param \OCP\Lock\ILockingProvider $provider * @param \OCP\Lock\ILockingProvider $provider
*/ */
public function releaseLock($path, $type, ILockingProvider $provider) { public function releaseLock($path, $type, ILockingProvider $provider) {
$this->storage->releaseLock($this->getSourcePath($path), $type, $provider); $this->getWrapperStorage()->releaseLock($this->getSourcePath($path), $type, $provider);
} }
/** /**
@ -450,7 +450,7 @@ class Jail extends Wrapper {
* @param \OCP\Lock\ILockingProvider $provider * @param \OCP\Lock\ILockingProvider $provider
*/ */
public function changeLock($path, $type, ILockingProvider $provider) { public function changeLock($path, $type, ILockingProvider $provider) {
$this->storage->changeLock($this->getSourcePath($path), $type, $provider); $this->getWrapperStorage()->changeLock($this->getSourcePath($path), $type, $provider);
} }
/** /**
@ -460,7 +460,7 @@ class Jail extends Wrapper {
* @return array * @return array
*/ */
public function resolvePath($path) { public function resolvePath($path) {
return [$this->storage, $this->getSourcePath($path)]; return [$this->getWrapperStorage(), $this->getSourcePath($path)];
} }
/** /**
@ -473,7 +473,7 @@ class Jail extends Wrapper {
if ($sourceStorage === $this) { if ($sourceStorage === $this) {
return $this->copy($sourceInternalPath, $targetInternalPath); return $this->copy($sourceInternalPath, $targetInternalPath);
} }
return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getSourcePath($targetInternalPath)); return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getSourcePath($targetInternalPath));
} }
/** /**
@ -486,6 +486,6 @@ class Jail extends Wrapper {
if ($sourceStorage === $this) { if ($sourceStorage === $this) {
return $this->rename($sourceInternalPath, $targetInternalPath); return $this->rename($sourceInternalPath, $targetInternalPath);
} }
return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getSourcePath($targetInternalPath)); return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getSourcePath($targetInternalPath));
} }
} }

View File

@ -64,7 +64,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function getId() { public function getId() {
return $this->storage->getId(); return $this->getWrapperStorage()->getId();
} }
/** /**
@ -74,7 +74,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function mkdir($path) { public function mkdir($path) {
return $this->storage->mkdir($path); return $this->getWrapperStorage()->mkdir($path);
} }
/** /**
@ -84,7 +84,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function rmdir($path) { public function rmdir($path) {
return $this->storage->rmdir($path); return $this->getWrapperStorage()->rmdir($path);
} }
/** /**
@ -94,7 +94,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return resource * @return resource
*/ */
public function opendir($path) { public function opendir($path) {
return $this->storage->opendir($path); return $this->getWrapperStorage()->opendir($path);
} }
/** /**
@ -104,7 +104,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function is_dir($path) { public function is_dir($path) {
return $this->storage->is_dir($path); return $this->getWrapperStorage()->is_dir($path);
} }
/** /**
@ -114,7 +114,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function is_file($path) { public function is_file($path) {
return $this->storage->is_file($path); return $this->getWrapperStorage()->is_file($path);
} }
/** /**
@ -125,7 +125,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return array * @return array
*/ */
public function stat($path) { public function stat($path) {
return $this->storage->stat($path); return $this->getWrapperStorage()->stat($path);
} }
/** /**
@ -135,7 +135,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function filetype($path) { public function filetype($path) {
return $this->storage->filetype($path); return $this->getWrapperStorage()->filetype($path);
} }
/** /**
@ -146,7 +146,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return int * @return int
*/ */
public function filesize($path) { public function filesize($path) {
return $this->storage->filesize($path); return $this->getWrapperStorage()->filesize($path);
} }
/** /**
@ -156,7 +156,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function isCreatable($path) { public function isCreatable($path) {
return $this->storage->isCreatable($path); return $this->getWrapperStorage()->isCreatable($path);
} }
/** /**
@ -166,7 +166,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function isReadable($path) { public function isReadable($path) {
return $this->storage->isReadable($path); return $this->getWrapperStorage()->isReadable($path);
} }
/** /**
@ -176,7 +176,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function isUpdatable($path) { public function isUpdatable($path) {
return $this->storage->isUpdatable($path); return $this->getWrapperStorage()->isUpdatable($path);
} }
/** /**
@ -186,7 +186,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function isDeletable($path) { public function isDeletable($path) {
return $this->storage->isDeletable($path); return $this->getWrapperStorage()->isDeletable($path);
} }
/** /**
@ -196,7 +196,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function isSharable($path) { public function isSharable($path) {
return $this->storage->isSharable($path); return $this->getWrapperStorage()->isSharable($path);
} }
/** /**
@ -207,7 +207,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return int * @return int
*/ */
public function getPermissions($path) { public function getPermissions($path) {
return $this->storage->getPermissions($path); return $this->getWrapperStorage()->getPermissions($path);
} }
/** /**
@ -217,7 +217,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function file_exists($path) { public function file_exists($path) {
return $this->storage->file_exists($path); return $this->getWrapperStorage()->file_exists($path);
} }
/** /**
@ -227,7 +227,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return int * @return int
*/ */
public function filemtime($path) { public function filemtime($path) {
return $this->storage->filemtime($path); return $this->getWrapperStorage()->filemtime($path);
} }
/** /**
@ -237,7 +237,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function file_get_contents($path) { public function file_get_contents($path) {
return $this->storage->file_get_contents($path); return $this->getWrapperStorage()->file_get_contents($path);
} }
/** /**
@ -248,7 +248,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function file_put_contents($path, $data) { public function file_put_contents($path, $data) {
return $this->storage->file_put_contents($path, $data); return $this->getWrapperStorage()->file_put_contents($path, $data);
} }
/** /**
@ -258,7 +258,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function unlink($path) { public function unlink($path) {
return $this->storage->unlink($path); return $this->getWrapperStorage()->unlink($path);
} }
/** /**
@ -269,7 +269,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function rename($path1, $path2) { public function rename($path1, $path2) {
return $this->storage->rename($path1, $path2); return $this->getWrapperStorage()->rename($path1, $path2);
} }
/** /**
@ -280,7 +280,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function copy($path1, $path2) { public function copy($path1, $path2) {
return $this->storage->copy($path1, $path2); return $this->getWrapperStorage()->copy($path1, $path2);
} }
/** /**
@ -291,7 +291,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return resource * @return resource
*/ */
public function fopen($path, $mode) { public function fopen($path, $mode) {
return $this->storage->fopen($path, $mode); return $this->getWrapperStorage()->fopen($path, $mode);
} }
/** /**
@ -302,7 +302,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function getMimeType($path) { public function getMimeType($path) {
return $this->storage->getMimeType($path); return $this->getWrapperStorage()->getMimeType($path);
} }
/** /**
@ -314,7 +314,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function hash($type, $path, $raw = false) { public function hash($type, $path, $raw = false) {
return $this->storage->hash($type, $path, $raw); return $this->getWrapperStorage()->hash($type, $path, $raw);
} }
/** /**
@ -324,7 +324,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return int * @return int
*/ */
public function free_space($path) { public function free_space($path) {
return $this->storage->free_space($path); return $this->getWrapperStorage()->free_space($path);
} }
/** /**
@ -334,7 +334,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return array * @return array
*/ */
public function search($query) { public function search($query) {
return $this->storage->search($query); return $this->getWrapperStorage()->search($query);
} }
/** /**
@ -346,7 +346,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function touch($path, $mtime = null) { public function touch($path, $mtime = null) {
return $this->storage->touch($path, $mtime); return $this->getWrapperStorage()->touch($path, $mtime);
} }
/** /**
@ -357,7 +357,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function getLocalFile($path) { public function getLocalFile($path) {
return $this->storage->getLocalFile($path); return $this->getWrapperStorage()->getLocalFile($path);
} }
/** /**
@ -371,7 +371,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* returning true for other changes in the folder is optional * returning true for other changes in the folder is optional
*/ */
public function hasUpdated($path, $time) { public function hasUpdated($path, $time) {
return $this->storage->hasUpdated($path, $time); return $this->getWrapperStorage()->hasUpdated($path, $time);
} }
/** /**
@ -385,7 +385,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getCache($path, $storage); return $this->getWrapperStorage()->getCache($path, $storage);
} }
/** /**
@ -399,7 +399,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getScanner($path, $storage); return $this->getWrapperStorage()->getScanner($path, $storage);
} }
@ -410,7 +410,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function getOwner($path) { public function getOwner($path) {
return $this->storage->getOwner($path); return $this->getWrapperStorage()->getOwner($path);
} }
/** /**
@ -424,28 +424,28 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getWatcher($path, $storage); return $this->getWrapperStorage()->getWatcher($path, $storage);
} }
public function getPropagator($storage = null) { public function getPropagator($storage = null) {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getPropagator($storage); return $this->getWrapperStorage()->getPropagator($storage);
} }
public function getUpdater($storage = null) { public function getUpdater($storage = null) {
if (!$storage) { if (!$storage) {
$storage = $this; $storage = $this;
} }
return $this->storage->getUpdater($storage); return $this->getWrapperStorage()->getUpdater($storage);
} }
/** /**
* @return \OC\Files\Cache\Storage * @return \OC\Files\Cache\Storage
*/ */
public function getStorageCache() { public function getStorageCache() {
return $this->storage->getStorageCache(); return $this->getWrapperStorage()->getStorageCache();
} }
/** /**
@ -455,7 +455,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string * @return string
*/ */
public function getETag($path) { public function getETag($path) {
return $this->storage->getETag($path); return $this->getWrapperStorage()->getETag($path);
} }
/** /**
@ -464,7 +464,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return true * @return true
*/ */
public function test() { public function test() {
return $this->storage->test(); return $this->getWrapperStorage()->test();
} }
/** /**
@ -473,7 +473,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool wrapped storage's isLocal() value * @return bool wrapped storage's isLocal() value
*/ */
public function isLocal() { public function isLocal() {
return $this->storage->isLocal(); return $this->getWrapperStorage()->isLocal();
} }
/** /**
@ -483,7 +483,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return bool * @return bool
*/ */
public function instanceOfStorage($class) { public function instanceOfStorage($class) {
return is_a($this, $class) or $this->storage->instanceOfStorage($class); return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class);
} }
/** /**
@ -494,7 +494,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return mixed * @return mixed
*/ */
public function __call($method, $args) { public function __call($method, $args) {
return call_user_func_array(array($this->storage, $method), $args); return call_user_func_array(array($this->getWrapperStorage(), $method), $args);
} }
/** /**
@ -506,7 +506,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return array * @return array
*/ */
public function getDirectDownload($path) { public function getDirectDownload($path) {
return $this->storage->getDirectDownload($path); return $this->getWrapperStorage()->getDirectDownload($path);
} }
/** /**
@ -515,7 +515,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return array [ available, last_checked ] * @return array [ available, last_checked ]
*/ */
public function getAvailability() { public function getAvailability() {
return $this->storage->getAvailability(); return $this->getWrapperStorage()->getAvailability();
} }
/** /**
@ -524,7 +524,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @param bool $isAvailable * @param bool $isAvailable
*/ */
public function setAvailability($isAvailable) { public function setAvailability($isAvailable) {
$this->storage->setAvailability($isAvailable); $this->getWrapperStorage()->setAvailability($isAvailable);
} }
/** /**
@ -534,7 +534,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @throws InvalidPathException * @throws InvalidPathException
*/ */
public function verifyPath($path, $fileName) { public function verifyPath($path, $fileName) {
$this->storage->verifyPath($path, $fileName); $this->getWrapperStorage()->verifyPath($path, $fileName);
} }
/** /**
@ -548,7 +548,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
return $this->copy($sourceInternalPath, $targetInternalPath); return $this->copy($sourceInternalPath, $targetInternalPath);
} }
return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
} }
/** /**
@ -562,7 +562,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
return $this->rename($sourceInternalPath, $targetInternalPath); return $this->rename($sourceInternalPath, $targetInternalPath);
} }
return $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
} }
/** /**
@ -570,7 +570,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return array * @return array
*/ */
public function getMetaData($path) { public function getMetaData($path) {
return $this->storage->getMetaData($path); return $this->getWrapperStorage()->getMetaData($path);
} }
/** /**
@ -580,8 +580,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @throws \OCP\Lock\LockedException * @throws \OCP\Lock\LockedException
*/ */
public function acquireLock($path, $type, ILockingProvider $provider) { public function acquireLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->acquireLock($path, $type, $provider); $this->getWrapperStorage()->acquireLock($path, $type, $provider);
} }
} }
@ -591,8 +591,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @param \OCP\Lock\ILockingProvider $provider * @param \OCP\Lock\ILockingProvider $provider
*/ */
public function releaseLock($path, $type, ILockingProvider $provider) { public function releaseLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->releaseLock($path, $type, $provider); $this->getWrapperStorage()->releaseLock($path, $type, $provider);
} }
} }
@ -602,8 +602,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @param \OCP\Lock\ILockingProvider $provider * @param \OCP\Lock\ILockingProvider $provider
*/ */
public function changeLock($path, $type, ILockingProvider $provider) { public function changeLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->changeLock($path, $type, $provider); $this->getWrapperStorage()->changeLock($path, $type, $provider);
} }
} }
} }

View File

@ -16,9 +16,9 @@ class MountPointTest extends \Test\TestCase {
->method('getId') ->method('getId')
->will($this->returnValue(123)); ->will($this->returnValue(123));
$loader = $this->getMock('\OCP\Files\Storage\IStorageFactory'); $loader = $this->getMock('\OC\Files\Storage\StorageFactory');
$loader->expects($this->once()) $loader->expects($this->once())
->method('getInstance') ->method('wrap')
->will($this->returnValue($storage)); ->will($this->returnValue($storage));
$mountPoint = new \OC\Files\Mount\MountPoint( $mountPoint = new \OC\Files\Mount\MountPoint(
@ -38,9 +38,9 @@ class MountPointTest extends \Test\TestCase {
} }
public function testInvalidStorage() { public function testInvalidStorage() {
$loader = $this->getMock('\OCP\Files\Storage\IStorageFactory'); $loader = $this->getMock('\OC\Files\Storage\StorageFactory');
$loader->expects($this->once()) $loader->expects($this->once())
->method('getInstance') ->method('wrap')
->will($this->throwException(new \Exception('Test storage init exception'))); ->will($this->throwException(new \Exception('Test storage init exception')));
$called = false; $called = false;