SAAS-135: Airtime status page reporting free space being incorrectly for Gluster FS mounts

-Done
This commit is contained in:
Martin Konecny 2012-01-04 14:18:40 -05:00
parent 00a05e146b
commit 7247f75563
2 changed files with 41 additions and 16 deletions

View file

@ -680,6 +680,18 @@ class Application_Model_Preference
return $val; return $val;
} }
public static function SetDiskQuota($value){
self::SetValue("disk_quota", $value, false);
}
public static function GetDiskQuota(){
$val = self::GetValue("disk_quota");
if(strlen($val) == 0) {
$val = "0";
}
return $val;
}
/* User specific preferences end */ /* User specific preferences end */
} }

View file

@ -184,14 +184,25 @@ class Application_Model_Systemstatus
} }
public static function GetDiskInfo(){ public static function GetDiskInfo(){
$partions = array();
if (isset($_SERVER['AIRTIME_SRV'])){
//connect to DB and find how much total space user has allocated.
$totalSpace = Application_Model_Preference::GetDiskQuota();
$storPath = Application_Model_MusicDir::getStorDir()->getDirectory();
list($usedSpace,) = preg_split("/[\s]+/", exec("du -s $storPath"));
$partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = $totalSpace - $usedSpace;
Logging::log($partitions[$totalSpace]->totalFreeSpace);
} else {
/* First lets get all the watched directories. Then we can group them /* First lets get all the watched directories. Then we can group them
* into the same paritions by comparing the partition sizes. */ * into the same partitions by comparing the partition sizes. */
$musicDirs = Application_Model_MusicDir::getWatchedDirs(); $musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = Application_Model_MusicDir::getStorDir(); $musicDirs[] = Application_Model_MusicDir::getStorDir();
$partions = array();
foreach($musicDirs as $md){ foreach($musicDirs as $md){
$totalSpace = disk_total_space($md->getDirectory()); $totalSpace = disk_total_space($md->getDirectory());
@ -199,10 +210,12 @@ class Application_Model_Systemstatus
$partitions[$totalSpace] = new StdClass; $partitions[$totalSpace] = new StdClass;
$partitions[$totalSpace]->totalSpace = $totalSpace; $partitions[$totalSpace]->totalSpace = $totalSpace;
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory()); $partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
} }
$partitions[$totalSpace]->dirs[] = $md->getDirectory(); $partitions[$totalSpace]->dirs[] = $md->getDirectory();
} }
}
return array_values($partitions); return array_values($partitions);
} }