From 835d6a9b6e1be4eab22d138e0ef01e608a5597bf Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 14 Dec 2011 01:16:14 +0100 Subject: [PATCH] save quota in human readable format (42 MB), should prevent some of the overflow related problems --- lib/fileproxy/quota.php | 4 +++- settings/ajax/setquota.php | 5 ++++- settings/users.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index f770c9cb32..94a49176ee 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -27,8 +27,10 @@ class OC_FileProxy_Quota extends OC_FileProxy{ private function getFreeSpace(){ - $usedSpace=OC_Filesystem::filesize(''); + $rootInfo=OC_FileCache::get(''); + $usedSpace=$rootInfo['size']; $totalSpace=OC_Preferences::getValue(OC_User::getUser(),'files','quota',0); + $totalSpace=OC_Helper::computerFileSize($totalSpace); if($totalSpace==0){ return 0; } diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index 5c07285cfc..d4e3c58ac1 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -6,10 +6,13 @@ require_once('../../lib/base.php'); OC_JSON::checkAdminUser(); $username = $_POST["username"]; + +//make sure the quota is in the expected format $quota= OC_Helper::computerFileSize($_POST["quota"]); +$quota=OC_Helper::humanFileSize($quota); // Return Success story OC_Preferences::setValue($username,'files','quota',$quota); -OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>OC_Helper::humanFileSize($quota)))); +OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota))); ?> diff --git a/settings/users.php b/settings/users.php index 686c4b6a9b..e5dcc04948 100644 --- a/settings/users.php +++ b/settings/users.php @@ -18,7 +18,7 @@ $users = array(); $groups = array(); foreach( OC_User::getUsers() as $i ){ - $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Helper::humanFileSize(OC_Preferences::getValue($i,'files','quota',0))); + $users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota',0)); } foreach( OC_Group::getGroups() as $i ){