Harmonize version reporting in ui and api

Everything should use the version from the VERSION file created by the installer like this.
This commit is contained in:
Lucas Bickel 2017-03-10 20:28:54 +01:00
parent e3785e25f9
commit bd18caf69d
8 changed files with 23 additions and 31 deletions

View File

@ -96,7 +96,6 @@ class Config {
$CC_CONFIG['facebook-app-api-key'] = $globalAirtimeConfigValues['facebook']['facebook_app_api_key'];
}
if(isset($values['demo']['demo'])){
$CC_CONFIG['demo'] = $values['demo']['demo'];
}
@ -104,10 +103,12 @@ class Config {
}
public static function setAirtimeVersion() {
$airtime_version = Application_Model_Preference::GetAirtimeVersion();
$uniqueid = Application_Model_Preference::GetUniqueId();
$buildVersion = @file_get_contents(self::$rootDir."/../VERSION");
self::$CC_CONFIG['airtime_version'] = md5($airtime_version.$buildVersion);
$version = @file_get_contents(self::$rootDir."/../VERSION");
if (!$version) {
// fallback to constant from constants.php if no other info is available
$version = LIBRETIME_MAJOR_VERSION;
}
self::$CC_CONFIG['airtime_version'] = trim($version);
}
public static function getConfig() {

View File

@ -32,8 +32,8 @@ define('LICENSE_URL' , 'http://www.gnu.org/licenses/agpl-3.0-standalone.h
define('AIRTIME_COPYRIGHT_DATE' , '2010-2015');
define('AIRTIME_REST_VERSION' , '1.1');
define('AIRTIME_API_VERSION' , '1.1');
// XXX: it's important that we upgrade this every time we add an upgrade!
define('AIRTIME_CODE_VERSION' , '2.5.16');
// XXX: it's important that we upgrade this on major version bumps, usually users get more exact info from VERSION in airtime root dir
define('LIBRETIME_MAJOR_VERSION', '3');
// grab values from env (i'll do this everywhere with a small function if we like it)
define('LIBRETIME_CONF_DIR', getenv('LIBRETIME_CONF_DIR') ? getenv('LIBRETIME_CONF_DIR') : '/etc/airtime');

View File

@ -105,8 +105,9 @@ class ApiController extends Zend_Controller_Action
public function versionAction()
{
$config = Config::getConfig();
$this->_helper->json->sendJson( array(
"airtime_version" => Application_Model_Preference::GetAirtimeVersion(),
"airtime_version" => $config['airtime_version'],
"api_version" => AIRTIME_API_VERSION));
}
@ -685,7 +686,8 @@ class ApiController extends Zend_Controller_Action
$this->_helper->json->sendJson(
array("jsonrpc" => "2.0", "error" => array("code" => $result['code'], "message" => $result['message']))
);
}*/
}
**/
}
public function uploadRecordedAction()
@ -944,10 +946,11 @@ class ApiController extends Zend_Controller_Action
{
$request = $this->getRequest();
$getDiskInfo = $request->getParam('diskinfo') == "true";
$config = Config::getConfig();
$status = array(
"platform"=>Application_Model_Systemstatus::GetPlatformInfo(),
"airtime_version"=>Application_Model_Preference::GetAirtimeVersion(),
"airtime_version"=>$config['airtime_version'],
"services"=>array(
"pypo"=>Application_Model_Systemstatus::GetPypoStatus(),
"liquidsoap"=>Application_Model_Systemstatus::GetLiquidsoapStatus(),

View File

@ -109,8 +109,9 @@ class DashboardController extends Zend_Controller_Action
public function aboutAction()
{
$config = Config::getConfig();
Zend_Layout::getMvcInstance()->assign('parent_page', 'Help');
$this->view->airtime_version = Application_Model_Preference::GetAirtimeVersion();
$this->view->airtime_version = $config['airtime_version'];
}
public function tableTestAction()

View File

@ -114,7 +114,7 @@ class LoginController extends Zend_Controller_Action
}
$this->view->form = $form;
$this->view->airtimeVersion = Application_Model_Preference::GetAirtimeVersion();
$this->view->airtimeVersion = $CC_CONFIG['airtime_version'];
$this->view->airtimeCopyright = AIRTIME_COPYRIGHT_DATE;
if (isset($CC_CONFIG['demo'])) {
$this->view->demo = $CC_CONFIG['demo'];

View File

@ -865,23 +865,12 @@ class Application_Model_Preference
self::setValue("schema_version", $version);
}
public static function GetAirtimeVersion()
{
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')) {
$version = exec("git rev-parse --short HEAD 2>/dev/null", $out, $return_code);
if ($return_code == 0) {
return self::getValue("system_version")."+".$version.":".time();
}
}
return self::getValue("system_version");
}
public static function GetLatestVersion()
{
$config = Config::getConfig();
$latest = self::getValue("latest_version");
if ($latest == null || strlen($latest) == 0) {
return self::GetAirtimeVersion();
return $config['airtime_version'];
} else {
return $latest;
}

View File

@ -29,8 +29,9 @@ class UpgradeManager
*/
public static function getSupportedSchemaVersions()
{
$config = Config::getConfig();
//What versions of the schema does the code support today:
return array(AIRTIME_CODE_VERSION);
return array($config['airtime_version']);
}
public static function checkIfUpgradeIsNeeded()
@ -277,7 +278,6 @@ class AirtimeUpgrader253 extends AirtimeUpgrader
Application_Model_Preference::setDiskUsage($diskUsage);
//update system_version in cc_pref and change some columns in cc_files
parent::_runUpgrade();
}
}

View File

@ -267,10 +267,8 @@ class AirtimeInstall
}
public static function GetAirtimeVersion()
{
$con = Propel::getConnection();
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1";
$version = $con->query($sql)->fetchColumn(0);
return $version;
$config = Config::getConfig();
return $config['airtime_version'];
}
public static function DeleteFilesRecursive($p_path)
{