From a521949bafdaba0cb94061967b6b8307bbbebc05 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jan 2014 15:41:56 +0100 Subject: Allow passing a root folder to get the used space from in the quota wrapper --- lib/private/files/storage/wrapper/quota.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/private/files') diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index a430e3e4617..83a5de5ca30 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -15,12 +15,18 @@ class Quota extends Wrapper { */ protected $quota; + /** + * @var string $freeSpaceRoot + */ + protected $sizeRoot; + /** * @param array $parameters */ public function __construct($parameters) { $this->storage = $parameters['storage']; $this->quota = $parameters['quota']; + $this->freeSpaceRoot = isset($parameters['root']) ? $parameters['root'] : ''; } protected function getSize($path) { @@ -43,7 +49,7 @@ class Quota extends Wrapper { if ($this->quota < 0) { return $this->storage->free_space($path); } else { - $used = $this->getSize(''); + $used = $this->getSize($this->freeSpaceRoot); if ($used < 0) { return \OC\Files\SPACE_NOT_COMPUTED; } else { -- cgit v1.2.3 From c8207312c73f61b2be4aa8ca1d9ae6a8c33453cf Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jan 2014 16:00:10 +0100 Subject: Fix phpdoc --- lib/private/files/storage/wrapper/quota.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/private/files') diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index 83a5de5ca30..2fc3119fc7d 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -16,7 +16,7 @@ class Quota extends Wrapper { protected $quota; /** - * @var string $freeSpaceRoot + * @var string $sizeRoot */ protected $sizeRoot; -- cgit v1.2.3 From 20c2aaab00e92d74547ccd6c964102e10ea34cbf Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jan 2014 16:26:54 +0100 Subject: Actually rename the variable --- lib/private/files/storage/wrapper/quota.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/private/files') diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index 2fc3119fc7d..16127403181 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -26,7 +26,7 @@ class Quota extends Wrapper { public function __construct($parameters) { $this->storage = $parameters['storage']; $this->quota = $parameters['quota']; - $this->freeSpaceRoot = isset($parameters['root']) ? $parameters['root'] : ''; + $this->sizeRoot = isset($parameters['root']) ? $parameters['root'] : ''; } protected function getSize($path) { @@ -49,7 +49,7 @@ class Quota extends Wrapper { if ($this->quota < 0) { return $this->storage->free_space($path); } else { - $used = $this->getSize($this->freeSpaceRoot); + $used = $this->getSize($this->sizeRoot); if ($used < 0) { return \OC\Files\SPACE_NOT_COMPUTED; } else { -- cgit v1.2.3 From 8cc97275200ec9b47d1cd0c38c88c0c076687104 Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Wed, 15 Jan 2014 12:49:47 +0100 Subject: mount: make location of mount.json configurable do not share users data with config files Signed-off-by: Tigran Mkrtchyan --- apps/files_external/lib/config.php | 6 ++---- config/config.sample.php | 3 +++ lib/private/files/filesystem.php | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/private/files') diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 01d588b3721..3118e1ac68d 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -352,9 +352,8 @@ class OC_Mount_Config { $phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php'; $jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json'; } else { - $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); $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)) { $mountPoints = json_decode(file_get_contents($jsonFile), true); @@ -379,8 +378,7 @@ class OC_Mount_Config { if ($isPersonal) { $file = OC_User::getHome(OCP\User::getUser()).'/mount.json'; } else { - $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data"); - $file = $datadir . '/mount.json'; + $file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json"); } $content = json_encode($data); @file_put_contents($file, $content); diff --git a/config/config.sample.php b/config/config.sample.php index 01abc583688..5018a781f24 100755 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -250,4 +250,7 @@ $CONFIG = array( /* whether usage of the instance should be restricted to admin users only */ 'singleuser' => false, + + /* where mount.json file should be stored, defaults to data/mount.json */ + 'mount_file' => '', ); diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index a83e9aa86d2..f5e723afab0 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -320,16 +320,16 @@ class Filesystem { else { 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 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 - if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($datadir . '/mount.json')) { - if (is_file($datadir . '/mount.json')) { - $mountConfig = json_decode(file_get_contents($datadir . '/mount.json'), true); + if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($mount_file)) { + if (is_file($mount_file)) { + $mountConfig = json_decode(file_get_contents($mount_file), true); } elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) { $mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php')); } -- cgit v1.2.3