pass mountpoint to storage wrapper callback
This commit is contained in:
parent
dbade19362
commit
e5c8fd37df
3 changed files with 13 additions and 10 deletions
|
@ -71,9 +71,10 @@ class MountPoint implements IMountPoint {
|
|||
}
|
||||
|
||||
$mountpoint = $this->formatPath($mountpoint);
|
||||
$this->mountPoint = $mountpoint;
|
||||
if ($storage instanceof Storage) {
|
||||
$this->class = get_class($storage);
|
||||
$this->storage = $this->loader->wrap($mountpoint, $storage);
|
||||
$this->storage = $this->loader->wrap($this, $storage);
|
||||
} else {
|
||||
// Update old classes to new namespace
|
||||
if (strpos($storage, 'OC_Filestorage_') !== false) {
|
||||
|
@ -82,7 +83,6 @@ class MountPoint implements IMountPoint {
|
|||
$this->class = $storage;
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
$this->mountPoint = $mountpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ class MountPoint implements IMountPoint {
|
|||
|
||||
if (class_exists($this->class)) {
|
||||
try {
|
||||
return $this->loader->getInstance($this->mountPoint, $this->class, $this->arguments);
|
||||
return $this->loader->getInstance($this, $this->class, $this->arguments);
|
||||
} catch (\Exception $exception) {
|
||||
$this->invalidStorage = true;
|
||||
if ($this->mountPoint === '/') {
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace OC\Files\Storage;
|
||||
|
||||
use OCP\Files\Config\IMountProviderCollection;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\Files\Storage\IStorageFactory;
|
||||
|
||||
class StorageFactory implements IStorageFactory {
|
||||
|
@ -55,23 +57,23 @@ class StorageFactory implements IStorageFactory {
|
|||
/**
|
||||
* Create an instance of a storage and apply the registered storage wrappers
|
||||
*
|
||||
* @param string|boolean $mountPoint
|
||||
* @param \OCP\Files\Mount\IMountPoint $mountPoint
|
||||
* @param string $class
|
||||
* @param array $arguments
|
||||
* @return \OCP\Files\Storage
|
||||
*/
|
||||
public function getInstance($mountPoint, $class, $arguments) {
|
||||
public function getInstance(IMountPoint $mountPoint, $class, $arguments) {
|
||||
return $this->wrap($mountPoint, new $class($arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|boolean $mountPoint
|
||||
* @param \OCP\Files\Mount\IMountPoint $mountPoint
|
||||
* @param \OCP\Files\Storage $storage
|
||||
* @return \OCP\Files\Storage
|
||||
*/
|
||||
public function wrap($mountPoint, $storage) {
|
||||
public function wrap(IMountPoint $mountPoint, $storage) {
|
||||
foreach ($this->storageWrappers as $wrapper) {
|
||||
$storage = $wrapper($mountPoint, $storage);
|
||||
$storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint);
|
||||
}
|
||||
return $storage;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
namespace OCP\Files\Storage;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
|
||||
/**
|
||||
* Creates storage instances and manages and applies storage wrappers
|
||||
|
@ -25,10 +26,10 @@ interface IStorageFactory {
|
|||
public function addStorageWrapper($wrapperName, $callback);
|
||||
|
||||
/**
|
||||
* @param string|boolean $mountPoint
|
||||
* @param \OCP\Files\Mount\IMountPoint $mountPoint
|
||||
* @param string $class
|
||||
* @param array $arguments
|
||||
* @return \OCP\Files\Storage
|
||||
*/
|
||||
public function getInstance($mountPoint, $class, $arguments);
|
||||
public function getInstance(IMountPoint $mountPoint, $class, $arguments);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue