diff --git a/lib/private/files/mount/mountpoint.php b/lib/private/files/mount/mountpoint.php index a187f4db1093..85c1c1b59cc2 100644 --- a/lib/private/files/mount/mountpoint.php +++ b/lib/private/files/mount/mountpoint.php @@ -11,6 +11,7 @@ use \OC\Files\Filesystem; use OC\Files\Storage\StorageFactory; use OC\Files\Storage\Storage; +use OC\Files\Storage\Wrapper\Wrapper; use OCP\Files\Mount\IMountPoint; class MountPoint implements IMountPoint { @@ -74,7 +75,11 @@ public function __construct($storage, $mountpoint, $arguments = null, $loader = $this->mountPoint = $mountpoint; if ($storage instanceof Storage) { $this->class = get_class($storage); - $this->storage = $this->loader->wrap($this, $storage); + $this->storage = $storage; + // only wrap if not already wrapped + if (!($this->storage instanceof Wrapper)) { + $this->storage = $this->loader->wrap($this, $this->storage); + } } else { // Update old classes to new namespace if (strpos($storage, 'OC_Filestorage_') !== false) { diff --git a/tests/lib/files/mount/mountpoint.php b/tests/lib/files/mount/mountpoint.php index 5a9c6de3e0ae..196ace0116bf 100644 --- a/tests/lib/files/mount/mountpoint.php +++ b/tests/lib/files/mount/mountpoint.php @@ -66,4 +66,25 @@ public function testInvalidStorage() { // storage wrapper never called $this->assertFalse($called); } + + public function testWrappedStorage() { + $storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Wrapper') + ->disableOriginalConstructor() + ->getMock(); + + $loader = $this->getMock('\OCP\Files\Storage\IStorageFactory'); + $loader->expects($this->never()) + ->method('getInstance'); + $loader->expects($this->never()) + ->method('wrap'); + + $mountPoint = new \OC\Files\Mount\MountPoint( + $storage, + '/mountpoint', + null, + $loader + ); + + $this->assertEquals($storage, $mountPoint->getStorage()); + } }