Merge pull request #6999 from kofemann/mount-config

mount: make location of mount.json configurable
This commit is contained in:
Lukas Reschke 2014-02-20 15:15:00 +01:00
commit c869e0116b
3 changed files with 10 additions and 9 deletions

View File

@ -352,9 +352,8 @@ class OC_Mount_Config {
$phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php'; $phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php';
$jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json'; $jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
} else { } else {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
$phpFile = OC::$SERVERROOT.'/config/mount.php'; $phpFile = OC::$SERVERROOT.'/config/mount.php';
$jsonFile = $datadir . '/mount.json'; $jsonFile = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
} }
if (is_file($jsonFile)) { if (is_file($jsonFile)) {
$mountPoints = json_decode(file_get_contents($jsonFile), true); $mountPoints = json_decode(file_get_contents($jsonFile), true);
@ -380,8 +379,7 @@ class OC_Mount_Config {
if ($isPersonal) { if ($isPersonal) {
$file = OC_User::getHome(OCP\User::getUser()).'/mount.json'; $file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
} else { } else {
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); $file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
$file = $datadir . '/mount.json';
} }
$content = json_encode($data); $content = json_encode($data);
@file_put_contents($file, $content); @file_put_contents($file, $content);

View File

@ -263,4 +263,7 @@ $CONFIG = array(
/* whether usage of the instance should be restricted to admin users only */ /* whether usage of the instance should be restricted to admin users only */
'singleuser' => false, 'singleuser' => false,
/* where mount.json file should be stored, defaults to data/mount.json */
'mount_file' => '',
); );

View File

@ -320,16 +320,16 @@ class Filesystem {
else { else {
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
} }
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); $mount_file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
//move config file to it's new position //move config file to it's new position
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) { if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
rename(\OC::$SERVERROOT . '/config/mount.json', $datadir . '/mount.json'); rename(\OC::$SERVERROOT . '/config/mount.json', $mount_file);
} }
// Load system mount points // Load system mount points
if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($datadir . '/mount.json')) { if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($mount_file)) {
if (is_file($datadir . '/mount.json')) { if (is_file($mount_file)) {
$mountConfig = json_decode(file_get_contents($datadir . '/mount.json'), true); $mountConfig = json_decode(file_get_contents($mount_file), true);
} elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) { } elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
$mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php')); $mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
} }