save quota in human readable format (42 MB), should prevent some of the overflow related problems

This commit is contained in:
Robin Appelman 2011-12-14 01:16:14 +01:00
parent a9e94a34c9
commit 835d6a9b6e
3 changed files with 8 additions and 3 deletions

View File

@ -27,8 +27,10 @@
class OC_FileProxy_Quota extends OC_FileProxy{ class OC_FileProxy_Quota extends OC_FileProxy{
private function getFreeSpace(){ 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_Preferences::getValue(OC_User::getUser(),'files','quota',0);
$totalSpace=OC_Helper::computerFileSize($totalSpace);
if($totalSpace==0){ if($totalSpace==0){
return 0; return 0;
} }

View File

@ -6,10 +6,13 @@ require_once('../../lib/base.php');
OC_JSON::checkAdminUser(); OC_JSON::checkAdminUser();
$username = $_POST["username"]; $username = $_POST["username"];
//make sure the quota is in the expected format
$quota= OC_Helper::computerFileSize($_POST["quota"]); $quota= OC_Helper::computerFileSize($_POST["quota"]);
$quota=OC_Helper::humanFileSize($quota);
// Return Success story // Return Success story
OC_Preferences::setValue($username,'files','quota',$quota); 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)));
?> ?>

View File

@ -18,7 +18,7 @@ $users = array();
$groups = array(); $groups = array();
foreach( OC_User::getUsers() as $i ){ 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 ){ foreach( OC_Group::getGroups() as $i ){