aboutsummaryrefslogtreecommitdiffstats
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 21:56:44 +0100
commita3592534ef9dfd93388c09e9aa6fce3ca45fc9ee (patch)
tree4eb23c1f3e3795e7e550ccb74231fed88f7a8713
parent4c00be49613fe14a03e996dd0768bcb7ef2795ab (diff)
downloadnextcloud-server-a3592534ef9dfd93388c09e9aa6fce3ca45fc9ee.tar.gz
nextcloud-server-a3592534ef9dfd93388c09e9aa6fce3ca45fc9ee.zip
always fall back to default share folder
-rw-r--r--apps/files_sharing/lib/helper.php15
-rw-r--r--apps/files_sharing/lib/sharedmount.php4
-rw-r--r--apps/files_sharing/tests/helper.php6
3 files changed, 20 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index 236be15a95a..3f1de7233ae 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -283,8 +283,21 @@ class Helper {
*/
public static function getShareFolder() {
$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 $shareFolder;
- return \OC\Files\Filesystem::normalizePath($shareFolder);
}
/**
diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php
index 47378593757..da00549541b 100644
--- a/apps/files_sharing/lib/sharedmount.php
+++ b/apps/files_sharing/lib/sharedmount.php
@@ -50,8 +50,8 @@ class SharedMount extends MountPoint 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 1d7093a1cf0..34a1389db77 100644
--- a/apps/files_sharing/tests/helper.php
+++ b/apps/files_sharing/tests/helper.php
@@ -52,9 +52,11 @@ class Test_Files_Sharing_Helper extends TestCase {
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
\OC::$server->getConfig()->deleteSystemValue('share_folder');