summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-03-26 21:56:44 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2015-03-26 22:46:43 +0100
commit0cdeeec82b66495f6070b84c1039ebd29150b704 (patch)
tree35586ed095bff232a85226f1573c04988479d483 /apps
parent32bd2d15e31b7947c269a7dc9641f29ce5e2714f (diff)
downloadnextcloud-server-0cdeeec82b66495f6070b84c1039ebd29150b704.tar.gz
nextcloud-server-0cdeeec82b66495f6070b84c1039ebd29150b704.zip
always fall back to default share folder
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/helper.php16
-rw-r--r--apps/files_sharing/lib/sharedmount.php4
-rw-r--r--apps/files_sharing/tests/helper.php6
3 files changed, 20 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index f444404c2b1..1b03fd24d54 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -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;
}
/**
diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php
index 4ad2d4e6b3e..3ffac0a5cb8 100644
--- a/apps/files_sharing/lib/sharedmount.php
+++ b/apps/files_sharing/lib/sharedmount.php
@@ -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(
diff --git a/apps/files_sharing/tests/helper.php b/apps/files_sharing/tests/helper.php
index 6169a9f5094..ed332f28d4c 100644
--- a/apps/files_sharing/tests/helper.php
+++ b/apps/files_sharing/tests/helper.php
@@ -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');