Commit d082e372 authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #15244 from owncloud/use_default_share_folder

always fall back to default share folder
parents c2909355 a3592534
......@@ -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);
}
/**
......
......@@ -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(
......
......@@ -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');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment