Allow storage wrappers to lazily initialize the source storage

This commit is contained in:
Robin Appelman 2016-08-22 12:23:55 +02:00
parent 379260732c
commit 2a2f1b9a00
1 changed files with 55 additions and 55 deletions

View File

@ -64,7 +64,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @return string
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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) {
$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) {
$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
*/
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) {
$storage = $this;
}
return $this->storage->getWatcher($path, $storage);
return $this->getWrapperStorage()->getWatcher($path, $storage);
}
public function getPropagator($storage = null) {
if (!$storage) {
$storage = $this;
}
return $this->storage->getPropagator($storage);
return $this->getWrapperStorage()->getPropagator($storage);
}
public function getUpdater($storage = null) {
if (!$storage) {
$storage = $this;
}
return $this->storage->getUpdater($storage);
return $this->getWrapperStorage()->getUpdater($storage);
}
/**
* @return \OC\Files\Cache\Storage
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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 ]
*/
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
*/
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
*/
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->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->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
*/
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
*/
public function acquireLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->acquireLock($path, $type, $provider);
if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->getWrapperStorage()->acquireLock($path, $type, $provider);
}
}
@ -591,8 +591,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->releaseLock($path, $type, $provider);
if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->getWrapperStorage()->releaseLock($path, $type, $provider);
}
}
@ -602,8 +602,8 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage {
* @param \OCP\Lock\ILockingProvider $provider
*/
public function changeLock($path, $type, ILockingProvider $provider) {
if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->storage->changeLock($path, $type, $provider);
if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
$this->getWrapperStorage()->changeLock($path, $type, $provider);
}
}
}