Merge branch 'cc-5709-airtime-analyzer-saas' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer-saas

This commit is contained in:
Albert Santoni 2014-05-05 12:42:49 -04:00
commit e963157a22
8 changed files with 6 additions and 145 deletions

View file

@ -36,37 +36,6 @@ class UpgradeController extends Zend_Controller_Action
$diskUsage = shell_exec("du -sb $storDir | awk '{print $1}'");
Application_Model_Preference::setDiskUsage($diskUsage);
//update application.ini
$iniFile = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."application.ini" : "/usr/share/airtime/application/configs/application.ini";
$newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH \"/modules\"\n".
"resources.frontController.plugins.putHandler = \"Zend_Controller_Plugin_PutHandler\"\n".
";load everything in the modules directory including models\n".
"resources.modules[] = \"\"\n";
$currentIniFile = file_get_contents($iniFile);
/* We want to add the new lines after a specific line. So we must find read the file
* into an array, find the key to which our desired line belongs, and use the key
* to split the file in two halves, $beginning and $end.
* The $newLines will go inbetween $beginning and $end
*/
$lines = explode("\n", $currentIniFile);
$key = array_search("resources.layout.layoutPath = APPLICATION_PATH \"/layouts/scripts/\"", $lines);
if (!$key) {
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini');
}
$beginning = implode("\n", array_slice($lines, 0, $key));
$end = implode("\n", array_slice($lines, $key));
if (!is_writeable($iniFile)) {
throw new Exception('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini - Permission denied.');
}
$file = new SplFileObject($iniFile, "w");
$file->fwrite($beginning."\n".$newLines.$end);
//TODO: clear out the cache

View file

@ -1440,7 +1440,8 @@ class Application_Model_Preference
public static function getDiskUsage()
{
return self::getValue("disk_usage");
$val = self::getValue("disk_usage");
return (strlen($val) == 0) ? 0 : $val;
}
public static function setDiskUsage($value)

View file

@ -219,6 +219,9 @@ class Application_Model_Systemstatus
$totalSpace = Application_Model_Preference::GetDiskQuota();
$usedSpace = Application_Model_Preference::getDiskUsage();
if (empty($usedSpace)) {
$usedSpace = 0;
}
/* $path = $_SERVER['AIRTIME_BASE']."etc/airtime/num_bytes.ini";
$arr = parse_ini_file($path);
@ -240,7 +243,7 @@ class Application_Model_Systemstatus
$diskInfo = self::GetDiskInfo();
$diskInfo = $diskInfo[0];
$diskUsage = $diskInfo->totalSpace - $diskInfo->totalFreeSpace;
if ($diskUsage >= $diskInfo->totalSpace) {
if ($diskUsage > 0 && $diskUsage >= $diskInfo->totalSpace) {
return true;
}