From 6fcc6c9a2657dce7617653f25be213c3297c3730 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Thu, 31 Dec 2020 13:49:45 +0800 Subject: [PATCH] upgrade --- .zd.conf | 2 +- res/en/messages.json | 46 ++++++++++++++++++++++++++++++++++++++ res/zh/messages.json | 46 ++++++++++++++++++++++++++++++++++++++ src/utils/config/config.go | 5 ++++- src/utils/const/const.go | 2 +- src/zd.go | 1 + 6 files changed, 99 insertions(+), 3 deletions(-) diff --git a/.zd.conf b/.zd.conf index 24b9b79d..c6f0b282 100644 --- a/.zd.conf +++ b/.zd.conf @@ -1,3 +1,3 @@ -Version = 1 +Version = 1.6 Language = zh diff --git a/res/en/messages.json b/res/en/messages.json index e4253471..11301864 100644 --- a/res/en/messages.json +++ b/res/en/messages.json @@ -164,6 +164,52 @@ { "id": "fail_to_exec_cmd", "translation": "Fail to exec command '%s', error is '%s'." + }, + + { + "id": "find_new_ver", + "translation": "Find new version %s" + }, + { + "id": "success_upgrade", + "translation": "Successfully upgrade from version %.1f to %s." + }, + { + "id": "fail_upgrade", + "translation": "Fail to upgrade from version %.1f to %s., err: %s." + }, + + { + "id": "download_fail", + "translation": "Download %s fail, error: %s." + }, + { + "id": "download_read_fail", + "translation": "Read download file %s fail, error: %s." + }, + { + "id": "download_write_fail", + "translation": "Write download file %s fail, error: %s." + }, + { + "id": "download_success", + "translation": "Successfully download %s to %s." + }, + { + "id": "success_update_config", + "translation": "Successfully update config file %s." + }, + { + "id": "perm_deny", + "translation": "Permission denied to file %s, please change work dir." + }, + { + "id": "fail_unzip", + "translation": "Fail to unzip file %s." + }, + { + "id": "fail_md5_check", + "translation": "Check file %s MD5 failed." } ] } diff --git a/res/zh/messages.json b/res/zh/messages.json index 76bd2e66..db6d6759 100644 --- a/res/zh/messages.json +++ b/res/zh/messages.json @@ -155,6 +155,52 @@ { "id": "fail_to_exec_cmd", "translation": "执行命令'%s'失败,错误消息为'%s'。" + }, + + { + "id": "find_new_ver", + "translation": "发现新版本%s。" + }, + { + "id": "success_upgrade", + "translation": "成功从版本%.1f升级到%s。" + }, + { + "id": "fail_upgrade", + "translation": "失败升级版本从%.1f到%s,错误 %s。" + }, + + { + "id": "download_fail", + "translation": "下载文件失败 %s,错误 %s。" + }, + { + "id": "download_read_fail", + "translation": "读取下载文件%s失败,错误 %s。" + }, + { + "id": "download_write_fail", + "translation": "写入下载文件%s失败,错误 %s。" + }, + { + "id": "download_success", + "translation": "成功下载文件%s到%s。" + }, + { + "id": "success_update_config", + "translation": "成功更新配置文件%s。" + }, + { + "id": "perm_deny", + "translation": "文件%s权限不足,建议切换工作目录。" + }, + { + "id": "fail_unzip", + "translation": "解压文件%s失败。" + }, + { + "id": "fail_md5_check", + "translation": "验证文件%s的MD5失败。" } ] } diff --git a/src/utils/config/config.go b/src/utils/config/config.go index b44046d0..86c07fef 100644 --- a/src/utils/config/config.go +++ b/src/utils/config/config.go @@ -57,7 +57,9 @@ func InitConfig() { func SaveConfig(conf model.Config) error { fileUtils.MkDirIfNeeded(filepath.Dir(vari.ConfigFile)) - conf.Version = constant.ConfigVer + if conf.Version == 0 { + conf.Version = constant.ConfigVer + } cfg := ini.Empty() cfg.ReflectFrom(&conf) @@ -131,6 +133,7 @@ func CheckConfigPermission() { func CheckConfigReady() { if !fileUtils.FileExist(vari.ConfigFile) { + logUtils.PrintTo(vari.ConfigFile + "no exist") if vari.RunMode == constant.RunModeServer { conf := model.Config{Language: "zh", Version: 1} SaveConfig(conf) diff --git a/src/utils/const/const.go b/src/utils/const/const.go index 0eb11d63..e9109f38 100644 --- a/src/utils/const/const.go +++ b/src/utils/const/const.go @@ -7,7 +7,7 @@ import ( ) const ( - AppName = "ztf" + AppName = "zendata" ) var ( diff --git a/src/zd.go b/src/zd.go index bf5c3411..6517d580 100644 --- a/src/zd.go +++ b/src/zd.go @@ -342,6 +342,7 @@ func InitServer() (err error) { upgradeService := serverService.NewUpgradeService() cronService := serverService.NewCronService(upgradeService) + cronService.Init() server := NewServer(config, defService, fieldService, sectionService, referService, rangesService, instancesService, textService, excelService, configService, resService, -- GitLab