]> source.dussan.org Git - nextcloud-server.git/commitdiff
Properly add trailing slash to mount point
authorVincent Petry <pvince81@owncloud.com>
Mon, 13 Apr 2015 10:36:47 +0000 (12:36 +0200)
committerVincent Petry <pvince81@owncloud.com>
Mon, 13 Apr 2015 10:36:47 +0000 (12:36 +0200)
Fixes resolving mount points when shared mount point's target name has
the same prefix as the source name

apps/files_sharing/tests/sharedmount.php
lib/private/files/mount/mountpoint.php
tests/lib/files/mount/mountpoint.php

index f64e191390538cf0103de4c1adbe75b5bd1b1987..ff4cb4c0e497a88aab1824d7d3939ab4230a1614 100644 (file)
@@ -144,14 +144,20 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
 
                self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
 
-               \OC\Files\Filesystem::rename($this->filename, "newFileName");
+               \OC\Files\Filesystem::rename($this->filename, $this->filename . '_renamed');
 
-               $this->assertTrue(\OC\Files\Filesystem::file_exists('newFileName'));
+               $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
                $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
 
                self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
                $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
-               $this->assertFalse(\OC\Files\Filesystem::file_exists("newFileName"));
+               $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
+
+               // rename back to original name
+               self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
+               \OC\Files\Filesystem::rename($this->filename . '_renamed', $this->filename);
+               $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename . '_renamed'));
+               $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
 
                //cleanup
                \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
index 30c0679094495c16bd505079bbdb850be313bcd6..f1e492c86031ff5680463d6b991d163f9cf1f359 100644 (file)
@@ -113,10 +113,12 @@ class MountPoint implements IMountPoint {
        }
 
        /**
+        * Sets the mount point path, relative to data/
+        *
         * @param string $mountPoint new mount point
         */
        public function setMountPoint($mountPoint) {
-               $this->mountPoint = $mountPoint;
+               $this->mountPoint = $this->formatPath($mountPoint);
        }
 
        /**
index 5a9c6de3e0aefb275a57e679a75ff24f253ffa00..29610e6058da8954ea3a7c462ec9aff5bac0f79d 100644 (file)
@@ -31,6 +31,10 @@ class MountPoint extends \Test\TestCase {
 
                $this->assertEquals($storage, $mountPoint->getStorage());
                $this->assertEquals(123, $mountPoint->getStorageId());
+               $this->assertEquals('/mountpoint/', $mountPoint->getMountPoint());
+
+               $mountPoint->setMountPoint('another');
+               $this->assertEquals('/another/', $mountPoint->getMountPoint());
        }
 
        public function testInvalidStorage() {