* @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;
}
/**
$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(
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');