SAAS-135: Airtime status page reporting free space being incorrectly for Gluster FS mounts
-Done
This commit is contained in:
parent
00a05e146b
commit
7247f75563
2 changed files with 41 additions and 16 deletions
|
@ -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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,24 +184,37 @@ class Application_Model_Systemstatus
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDiskInfo(){
|
public static function GetDiskInfo(){
|
||||||
/* First lets get all the watched directories. Then we can group them
|
|
||||||
* into the same paritions by comparing the partition sizes. */
|
|
||||||
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
|
|
||||||
$musicDirs[] = Application_Model_MusicDir::getStorDir();
|
|
||||||
|
|
||||||
|
|
||||||
$partions = array();
|
$partions = array();
|
||||||
|
|
||||||
foreach($musicDirs as $md){
|
if (isset($_SERVER['AIRTIME_SRV'])){
|
||||||
$totalSpace = disk_total_space($md->getDirectory());
|
//connect to DB and find how much total space user has allocated.
|
||||||
|
$totalSpace = Application_Model_Preference::GetDiskQuota();
|
||||||
if (!isset($partitions[$totalSpace])){
|
|
||||||
$partitions[$totalSpace] = new StdClass;
|
|
||||||
$partitions[$totalSpace]->totalSpace = $totalSpace;
|
|
||||||
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
|
$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
|
||||||
|
* into the same partitions by comparing the partition sizes. */
|
||||||
|
$musicDirs = Application_Model_MusicDir::getWatchedDirs();
|
||||||
|
$musicDirs[] = Application_Model_MusicDir::getStorDir();
|
||||||
|
|
||||||
|
foreach($musicDirs as $md){
|
||||||
|
$totalSpace = disk_total_space($md->getDirectory());
|
||||||
|
|
||||||
|
if (!isset($partitions[$totalSpace])){
|
||||||
|
$partitions[$totalSpace] = new StdClass;
|
||||||
|
$partitions[$totalSpace]->totalSpace = $totalSpace;
|
||||||
|
$partitions[$totalSpace]->totalFreeSpace = disk_free_space($md->getDirectory());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$partitions[$totalSpace]->dirs[] = $md->getDirectory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($partitions);
|
return array_values($partitions);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue