diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index c460159ece..140d892652 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -293,7 +293,7 @@ class Filesystem { } $mount = self::$mounts->find($path); if ($mount) { - return array($mount->getStorage(), $mount->getInternalPath($path)); + return array($mount->getStorage(), rtrim($mount->getInternalPath($path), '/')); } else { return array(null, null); } diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 158c964fd0..5e42e5ffd0 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -729,6 +729,22 @@ class View extends \Test\TestCase { ); } + public function testFileView() { + $storage = new Temporary(array()); + $scanner = $storage->getScanner(); + $storage->file_put_contents('foo.txt', 'bar'); + \OC\Files\Filesystem::mount($storage, array(), '/test/'); + $scanner->scan(''); + $view = new \OC\Files\View('/test/foo.txt'); + + $this->assertEquals('bar', $view->file_get_contents('')); + $fh = tmpfile(); + fwrite($fh, 'foo'); + rewind($fh); + $view->file_put_contents('', $fh); + $this->assertEquals('foo', $view->file_get_contents('')); + } + /** * @dataProvider tooLongPathDataProvider * @expectedException \OCP\Files\InvalidPathException