From e5c8fd37df9a5727bdfdf3664390b911a67a617a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 5 Mar 2015 12:28:17 +0100 Subject: [PATCH] pass mountpoint to storage wrapper callback --- lib/private/files/mount/mountpoint.php | 6 +++--- lib/private/files/storage/storagefactory.php | 12 +++++++----- lib/public/files/storage/istoragefactory.php | 5 +++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/private/files/mount/mountpoint.php b/lib/private/files/mount/mountpoint.php index 85edb7cb57..0442a36903 100644 --- a/lib/private/files/mount/mountpoint.php +++ b/lib/private/files/mount/mountpoint.php @@ -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 === '/') { diff --git a/lib/private/files/storage/storagefactory.php b/lib/private/files/storage/storagefactory.php index fa6dea2537..b43a6f737c 100644 --- a/lib/private/files/storage/storagefactory.php +++ b/lib/private/files/storage/storagefactory.php @@ -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; } diff --git a/lib/public/files/storage/istoragefactory.php b/lib/public/files/storage/istoragefactory.php index 50c844af2e..7d4fa55e41 100644 --- a/lib/public/files/storage/istoragefactory.php +++ b/lib/public/files/storage/istoragefactory.php @@ -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); }