]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix resolving paths for views rooted in a file
authorRobin Appelman <icewind@owncloud.com>
Mon, 26 Jan 2015 16:48:09 +0000 (17:48 +0100)
committerRobin Appelman <icewind@owncloud.com>
Thu, 29 Jan 2015 11:47:11 +0000 (12:47 +0100)
lib/private/files/filesystem.php
tests/lib/files/view.php

index c460159ece356c009f83c175966ea6f14fe320a0..140d892652f9d564817dad151eea8e7ceab3432b 100644 (file)
@@ -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);
                }
index 158c964fd0d0d701481cfe65f09f11043bd5d023..5e42e5ffd0fd959e4fdb8e271decea473cb7e0f1 100644 (file)
@@ -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