|
@@ -2745,10 +2745,11 @@ ErrorCodeEnum CUpgradeTaskFSM::SetRunSucceed(const char* pPackFile)
|
|
|
|
|
|
ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("begin UpgradeToNewVersion");
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("begin UpgradeToNewVersion");
|
|
|
//获取新版本号
|
|
|
if(m_currentTask.NewVersion.IsNullOrEmpty()){
|
|
|
if(m_currentTask.pack_version.IsNullOrEmpty()){
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("task NewVersion is empty , no need to write");
|
|
|
return Error_Succeed;
|
|
|
}else{
|
|
|
DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("NewVersion is null, pack_version=[%s] is not null,UpgradeToNewVersion fail, taskID=[%s]",m_currentTask.pack_version.GetData(), m_currentTask.upgradeTaskId.GetData());
|
|
@@ -2773,7 +2774,6 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
//修改active配置
|
|
|
CSimpleStringA strActiveFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "active.txt", rootVerPath.GetData());
|
|
|
if(!ExistsFileA(strActiveFile.GetData())){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail,active file is not exist");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,"UpgradeToNewVersion fail, active file is not exist");
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
@@ -2787,13 +2787,11 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
}
|
|
|
FILE* fp = fopen(strActiveFile.GetData(),"wb+");
|
|
|
if(fp==NULL){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, open write active.txt fail, err=%d",(int)GetLastError()).GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
int ret = fwrite(m_currentTask.NewVersion.GetData(),m_currentTask.NewVersion.GetLength(),1,fp);
|
|
|
if(ret!=1){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "write active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, write active.txt fail, err=%d",(int)GetLastError()).GetData());
|
|
|
fclose(fp);
|
|
|
if(backupSucc){
|
|
@@ -2815,22 +2813,21 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
if (ExistsFileA(strBackupActiveFile.GetData())) {
|
|
|
RemoveFileA(strBackupActiveFile.GetData());
|
|
|
}
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("write active.txt succ, version[%s]", m_currentTask.NewVersion.GetData());
|
|
|
}
|
|
|
|
|
|
//重新读active文件,看文件内容是什么
|
|
|
fp = fopen(strActiveFile.GetData(),"rb");
|
|
|
if(fp==NULL){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, open read active.txt fail, err=%d",(int)GetLastError()).GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
char cVer[16] = {0};
|
|
|
int re = fread(cVer,m_currentTask.NewVersion.GetLength(),1,fp);
|
|
|
if(re!=1){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "Read active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, read active.txt fail, err=%d",(int)GetLastError()).GetData());
|
|
|
}else{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read active.txt, version[%s]", cVer);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read rewritten file active.txt, version[%s]", cVer);
|
|
|
}
|
|
|
fclose(fp);
|
|
|
return Error_Succeed;
|
|
@@ -2843,13 +2840,11 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
}
|
|
|
FILE* fp = fopen(strActiveFile.GetData(),"wb+");
|
|
|
if(fp==NULL){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL, CSimpleStringA::Format("UpgradeToNewVersion fail, open write active.txt fail, err=%d", errno).GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
int ret = fwrite(m_currentTask.NewVersion.GetData(),m_currentTask.NewVersion.GetLength(),1,fp);
|
|
|
if(ret!=1){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "write active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL, CSimpleStringA::Format("UpgradeToNewVersion fail, write active.txt fail, err=%d", errno).GetData());
|
|
|
fclose(fp);
|
|
|
if (backupSucc) {
|
|
@@ -2871,22 +2866,21 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
|
|
|
if (ExistsFileA(strBackupActiveFile.GetData())) {
|
|
|
RemoveFileA(strBackupActiveFile.GetData());
|
|
|
}
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("write active.txt succ, version[%s]", m_currentTask.NewVersion.GetData());
|
|
|
}
|
|
|
|
|
|
//重新读active文件,看文件内容是什么
|
|
|
fp = fopen(strActiveFile.GetData(),"rb");
|
|
|
if(fp==NULL){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, open read active.txt fail, err=%d", errno).GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
char cVer[16] = {0};
|
|
|
int re = fread(cVer,m_currentTask.NewVersion.GetLength(),1,fp);
|
|
|
if(re!=1){
|
|
|
- //LogError(Severity_Low, Error_Unexpect, 0, "Read active.txt fail");
|
|
|
LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, read active.txt fail, err=%d", errno).GetData());
|
|
|
}else{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read active.txt, version[%s]", cVer);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read rewritten file active.txt, version[%s]", cVer);
|
|
|
}
|
|
|
fclose(fp);
|
|
|
return Error_Succeed;
|