]> source.dussan.org Git - nextcloud-server.git/commitdiff
always fall back to default share folder
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 26 Mar 2015 20:56:44 +0000 (21:56 +0100)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 26 Mar 2015 21:46:43 +0000 (22:46 +0100)
apps/files_sharing/lib/helper.php
apps/files_sharing/lib/sharedmount.php
apps/files_sharing/tests/helper.php

index f444404c2b18e458055291e3ae37b865713d5efe..1b03fd24d5419ce7332aab3120b32b3982c664bd 100644 (file)
@@ -243,9 +243,21 @@ class Helper {
         * @return string
         */
        public static function getShareFolder() {
-               $shareFolder = \OCP\Config::getSystemValue('share_folder', '/');
+               $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/');
+               $shareFolder = \OC\Files\Filesystem::normalizePath($shareFolder);
+
+               if (!\OC\Files\Filesystem::file_exists($shareFolder)) {
+                       $dir = '';
+                       $subdirs = explode('/', $shareFolder);
+                       foreach ($subdirs as $subdir) {
+                               $dir = $dir . '/' . $subdir;
+                               if (!\OC\Files\Filesystem::is_dir($dir)) {
+                                       \OC\Files\Filesystem::mkdir($dir);
+                               }
+                       }
+               }
 
-               return \OC\Files\Filesystem::normalizePath($shareFolder);
+               return $shareFolder;
        }
 
        /**
index 4ad2d4e6b3e205648e9bccb11fce7b4867013741..3ffac0a5cb8391556c68097ea3eb2673474e669f 100644 (file)
@@ -35,8 +35,8 @@ class SharedMount extends Mount implements MoveableMount {
                $mountPoint = basename($share['file_target']);
                $parent = dirname($share['file_target']);
 
-               while (!\OC\Files\Filesystem::is_dir($parent)) {
-                       $parent = dirname($parent);
+               if (!\OC\Files\Filesystem::is_dir($parent)) {
+                       $parent = Helper::getShareFolder();
                }
 
                $newMountPoint = \OCA\Files_Sharing\Helper::generateUniqueTarget(
index 6169a9f50942d04cef3433e9b5fc1cc388945776..ed332f28d4ceedc0a88b06e59f28de0e095b57ae 100644 (file)
@@ -29,9 +29,11 @@ class Test_Files_Sharing_Helper extends Test_Files_Sharing_Base {
        function testSetGetShareFolder() {
                $this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder());
 
-               \OCA\Files_Sharing\Helper::setShareFolder('/Shared');
+               \OCA\Files_Sharing\Helper::setShareFolder('/Shared/Folder');
 
-               $this->assertSame('/Shared', \OCA\Files_Sharing\Helper::getShareFolder());
+               $sharedFolder = \OCA\Files_Sharing\Helper::getShareFolder();
+               $this->assertSame('/Shared/Folder', \OCA\Files_Sharing\Helper::getShareFolder());
+               $this->assertTrue(\OC\Files\Filesystem::is_dir($sharedFolder));
 
                // cleanup
                \OCP\Config::deleteSystemValue('share_folder');