Browse Source

Z991239-4900 #comment 同步升级实体代码

Signed-Off-By: commit-hook
刘文涛80174520 2 years ago
parent
commit
c8e7d078b7

+ 8 - 0
Module/mod_UpgradeMgr/UpgradeManager_def_g.h

@@ -28,6 +28,14 @@ namespace UpgradeManager {
 #define UpgradeMgrService_MethodSignature_RegistManualPack -1924952337
 #define UpgradeMgrService_MethodSignature_GetManualPacks -905215373
 
+#define UpgradeMgrService_LogCode_GetUpgradeState "QLR040250600"
+#define UpgradeMgrService_LogCode_RegistLocalPack "QLR040250601"
+#define UpgradeMgrService_LogCode_CancelUpdate "QLR040250602"
+#define UpgradeMgrService_LogCode_RollbackUpdate "QLR040250603"
+#define UpgradeMgrService_LogCode_SwitchUpgrade "QLR040250604"
+#define UpgradeMgrService_LogCode_RegistManualPack "QLR040250605"
+#define UpgradeMgrService_LogCode_GetManualPacks "QLR040250606"
+
 struct UpgradeMgrService_GetUpgradeState_Req
 {
 

+ 201 - 4
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -1725,7 +1725,11 @@ namespace Task
 								if(remove(dPackPath)==0){
 									DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadPack")("delete download old pack succ ", dPackPath);
 									if(rename(dPackPathTemp.GetData(),dPackPath)!=0){
+#ifdef RVC_OS_WIN
+										errMsg = CSimpleStringA::Format("exist old file,remove temp file fail, error=%d",(int)GetLastError()).GetData();
+#else
 										errMsg = CSimpleStringA::Format("exist old file,remove temp file fail, error=%d", errno).GetData();
+#endif										
 										LogWarn(Severity_Middle, Error_Exception, ERR_TASK_DOWNLOAD_PACK_FAIL,errMsg.GetData());
 										delete[] content;
 										return 4;//下载失败,移动文件失败
@@ -1734,14 +1738,22 @@ namespace Task
 										return 1;//成功返回
 									}
 								}else{
+#ifdef RVC_OS_WIN
+									errMsg = CSimpleStringA::Format("delete download old pack fail ,error:%d",(int)GetLastError()).GetData();
+#else
 									errMsg = CSimpleStringA::Format("delete download old pack fail ,error:%d", errno).GetData();
+#endif
 									LogWarn(Severity_Middle, Error_Exception, ERR_TASK_DOWNLOAD_PACK_FAIL,errMsg.GetData());
 									delete[] content;
 									return 4;//下载失败,删除旧文件失败
 								}
 							}else{
 								if(rename(dPackPathTemp.GetData(),dPackPath)!=0){
+#ifdef RVC_OS_WIN
+									errMsg = CSimpleStringA::Format("not exist old file,remove temp file fail, error=%d",(int)GetLastError()).GetData();
+#else
 									errMsg = CSimpleStringA::Format("not exist old file,remove temp file fail, error=%d", errno).GetData();
+#endif
 									LogWarn(Severity_Middle, Error_Exception, ERR_TASK_DOWNLOAD_PACK_FAIL,errMsg.GetData());
 									delete[] content;
 									return 4;//移动文件失败
@@ -1757,7 +1769,11 @@ namespace Task
 							if(remove(dPackPathTemp.GetData())==0){
 								DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadPack")("delete download temp pack succ ,%s", dPackPathTemp.GetData());
 							}else{
+#ifdef RVC_OS_WIN							
+								DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadPack")("delete download temp pack fail ,%s  error:%d", dPackPathTemp.GetData(), GetLastError());
+#else
 								DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadPack")("delete download temp pack fail ,%s  error:%d", dPackPathTemp.GetData(), errno);
+#endif								
 							}
 							delete[] content;
 							return 4;//下载失败,hash不对
@@ -1991,16 +2007,26 @@ ErrorCodeEnum CUpgradeTaskFSM::CreateNewVersion(CVersion NewSoftwareVersion,CSim
 	{
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("new version dir [%s] already exist, delete it", strNewVerPath.GetData());
 		if(!RemoveDirRecursiveA(strNewVerPath.GetData())){
+#ifdef RVC_OS_WIN
+			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("Create new version fail, delete already exist new version is fail:%d",GetLastError());
+			strErrInfo = CSimpleStringA::Format("Create new version fail, delete already exist new version is fail:%d",(int)GetLastError());
+#else
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("Create new version fail, delete already exist new version is fail:%d", errno);
 			strErrInfo = CSimpleStringA::Format("Create new version fail, delete already exist new version is fail:%d", errno);
+#endif		
 			return Error_Bug;
 		}
 	}
 
 	if (!CreateDirA(strNewVerPath.GetData(), TRUE))
 	{
+#ifdef RVC_OS_WIN
+		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("Create new version dir fail: %d", GetLastError());
+		strErrInfo = CSimpleStringA::Format("create new version dir fail: %d", (int)GetLastError());
+#else
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("Create new version dir fail: %d", errno);
 		strErrInfo = CSimpleStringA::Format("create new version dir fail: %d", errno);
+#endif	
 		return Error_Unexpect;
 	}
 	DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("CreateNewVersion")("create new version dir succ, dir = %s",strNewVerPath.GetData());
@@ -2112,7 +2138,11 @@ ErrorCodeEnum CUpgradeTaskFSM::ClearUpgradeFailVersion(CVersion NewSoftwareVersi
 	if (ExistsDirA(strNewVerPath.GetData()))
 	{
 		if(!RemoveDirRecursiveA(strNewVerPath.GetData())){
+#ifdef RVC_OS_WIN
+			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ClearUpgradeFailVersion")("ClearUpgradeFailVersion fail, delete temp Version [%s] is fail:%d",strNewVerPath.GetData(),(int)GetLastError());
+#else
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ClearUpgradeFailVersion")("ClearUpgradeFailVersion fail, delete temp Version [%s] is fail:%d", strNewVerPath.GetData(), errno);
+#endif
 			return Error_Bug;
 		}else{
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ClearUpgradeFailVersion")("ClearUpgradeFailVersion succ, delete temp Version [%s] ", strNewVerPath.GetData());
@@ -2386,8 +2416,14 @@ int CUpgradeTaskFSM::ExecRunCmd(CSimpleStringA &strErrMsg,CInstallStep* ins)
 #endif
 		if(ret!=0){
 			//程序执行异常,结果未知
+#ifdef RVC_OS_WIN
+			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ExecRunCmd")("ExecRunCmd is fail, system_on exec unknown ,err=%s",err.GetData());
+			strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail, system_on exec unknown ,err=%s",err.GetData());
+#else
 			DbgWithLink(LOG_LEVEL_ERROR,LOG_TYPE_SYSTEM).setAPI("ExecRunCmd")("ExecRunCmd is fail, system_on exec unknown , ret=%d, err=%s",ret, strerror(errno));
 			strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail, system_on exec unknown  ret=%d, err=%s", ret, strerror(errno));
+#endif			
+
 			return -1;//未知结果返回
 
 		}else{
@@ -2412,8 +2448,13 @@ int CUpgradeTaskFSM::ExecRunCmd(CSimpleStringA &strErrMsg,CInstallStep* ins)
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ExecRunCmd")("ExecRunCmd is succ,[%s] ", destPath.GetData());
 				return 1;//成功
 			}else{
+#ifdef RVC_OS_WIN
+				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("ExecRunCmd")("ExecRunCmd is fail,errorCode = %s", eErrorCode.GetData());
+				strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail,errorCode = %s", eErrorCode.GetData());
+#else
 				DbgWithLink(LOG_LEVEL_ERROR,LOG_TYPE_SYSTEM).setAPI("ExecRunCmd")("ExecRunCmd is fail,errorCode = %s,%s", eErrorCode.GetData(), strErrMsg.GetData());
 				strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail,errorCode = %s,%s", eErrorCode.GetData(), strErrMsg.GetData());
+#endif			
 				return 0;//失败
 			}
 		}
@@ -2883,7 +2924,11 @@ ErrorCodeEnum CUpgradeTaskFSM::CopyFileOperate(const char* srcPath, const char*
 	if (bRet){
 		RemoveFileReadOnlyAttributeA(destPath);
 	}else{
+#ifdef RVC_OS_WIN
+		strErrMsg = CSimpleStringA::Format("CopyFileOperate copy file fail:%d", GetLastError());
+#else
 		strErrMsg = CSimpleStringA::Format("CopyFileOperate copy file fail:%d", errno);
+#endif
 	}
 	ErrorCodeEnum rc = bRet ? Error_Succeed : Error_Unexpect;
 	return rc;
@@ -2946,6 +2991,59 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
 			return Error_Unexpect;
 		}
 		//先做active文件备份,后面写入失败再copy回去
+#ifdef RVC_OS_WIN
+		bool backupSucc = true;
+		CSimpleStringA strBackupActiveFile = CSimpleStringA::Format("%s\\back_active.txt", rootVerPath.GetData());
+		if(!CopyFileA(strActiveFile.GetData(),strBackupActiveFile.GetData(),FALSE)){
+			LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, back up active.txt fail, err=%d",(int)GetLastError()).GetData());
+			backupSucc = false;
+		}
+		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){
+				if(CopyFileA(strBackupActiveFile.GetData(),strActiveFile.GetData(),FALSE)){
+					RemoveFileA(strBackupActiveFile.GetData());
+					DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("UpgradeToNewVersion")("back_active.txt copy to active.txt is succ");
+				}else{
+					LogWarn(Severity_Middle, Error_Exception, ERR_TASK_UPDATE_ACTIVE_FAIL,CSimpleStringA::Format("UpgradeToNewVersion fail, back_active.txt copy to active.txt is fail, err=%d",(int)GetLastError()).GetData());
+				}
+			}
+			return Error_Unexpect;
+		}else{
+			fflush(fp);
+			fclose(fp);
+			if (ExistsFileA(strBackupActiveFile.GetData())) {
+				RemoveFileA(strBackupActiveFile.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("UpgradeToNewVersion")("read active.txt, version[%s]", cVer);
+		}
+		fclose(fp);
+		return Error_Succeed;
+#else
 		bool backupSucc = true;
 		CSimpleStringA strBackupActiveFile = CSimpleStringA::Format("%s\\back_active.txt", rootVerPath.GetData());
 		if (fileutil_copy_file( strBackupActiveFile.GetData(),strActiveFile.GetData())!=0) {
@@ -2997,6 +3095,7 @@ ErrorCodeEnum CUpgradeTaskFSM::UpgradeToNewVersion()
 		}
 		fclose(fp);
 		return Error_Succeed;
+#endif
 	}
 
 
@@ -3039,6 +3138,58 @@ ErrorCodeEnum CUpgradeTaskFSM::RollBackToHistoryVersion(CVersion historyVersion)
 		return Error_Unexpect;
 	}
 	//先做active文件备份,后面写入失败再copy回去
+#ifdef RVC_OS_WIN
+	bool backupSucc = true;
+	CSimpleStringA strBackupActiveFile = CSimpleStringA::Format("%s\\Rollback_active.txt", rootVerPath.GetData());
+	if(!CopyFileA(strActiveFile.GetData(),strBackupActiveFile.GetData(),FALSE)){
+		LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL,CSimpleStringA::Format("RRollBackToHistoryVersion fail, back up active.txt fail, err=%d",(int)GetLastError()).GetData());
+		backupSucc = false;
+	}
+
+	FILE* fp = fopen(strActiveFile.GetData(),"wb+");
+	if(fp==NULL){
+		LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL, CSimpleStringA::Format("RRollBackToHistoryVersion fail, open write active.txt fail,err=%d", (int)GetLastError()).GetData());
+		return Error_Unexpect;
+	}
+	int ret = fwrite(strHisVersion.GetData(),strHisVersion.GetLength(),1,fp);
+	if(ret!=1){
+		LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL, CSimpleStringA::Format("RRollBackToHistoryVersion fail, write active.txt fail,err=%d", (int)GetLastError()).GetData());
+		fclose(fp);
+		if(backupSucc){
+			if(CopyFileA(strBackupActiveFile.GetData(),strActiveFile.GetData(),FALSE)){
+				RemoveFileA(strBackupActiveFile.GetData());
+				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RollBackToHistoryVersion")("Rollback_active.txt copy to active.txt is succ");
+			}else{
+				LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL,CSimpleStringA::Format("RRollBackToHistoryVersion fail, Rollback_active.txt copy to active.txt is fail, err=%d",(int)GetLastError()).GetData());
+			}
+		}
+		return Error_Unexpect;
+	}else{
+		fflush(fp);
+		fclose(fp);
+		if (ExistsFileA(strBackupActiveFile.GetData())) {
+			RemoveFileA(strBackupActiveFile.GetData());
+		}
+	}
+
+	//重新读active文件,看文件内容是什么
+	fp = fopen(strActiveFile.GetData(),"rb");
+	if(fp==NULL){
+		LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL, CSimpleStringA::Format("RRollBackToHistoryVersion fail, open read active.txt fail,err=%d", (int)GetLastError()).GetData());
+		return Error_Unexpect;
+	}
+	char cVer[16] = {0};
+	int re = fread(cVer,strHisVersion.GetLength(),1,fp);
+	if(re!=1){
+		LogWarn(Severity_Middle, Error_Exception, ERR_TASK_ROLL_BACK_ACTIVE_FAIL, CSimpleStringA::Format("RRollBackToHistoryVersion fail, Read active.txt fail,err=%d", (int)GetLastError()).GetData());
+	}else{
+		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RollBackToHistoryVersion")("read active.txt, version[%s]", cVer);
+	}
+	fclose(fp);
+
+	DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RollBackToHistoryVersion")("set rollback to history version [%s] succeed", (const char*)strHisVersion);
+	return Error_Succeed;
+#else
 	bool backupSucc = true;
 	CSimpleStringA strBackupActiveFile = CSimpleStringA::Format("%s\\Rollback_active.txt", rootVerPath.GetData());
 	if (fileutil_copy_file(strBackupActiveFile.GetData(), strActiveFile.GetData())!=0) {
@@ -3089,6 +3240,7 @@ ErrorCodeEnum CUpgradeTaskFSM::RollBackToHistoryVersion(CVersion historyVersion)
 
 	DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RollBackToHistoryVersion")("set rollback to history version [%s] succeed", (const char*)strHisVersion);
 	return Error_Succeed;
+#endif	
 }
 
 void CUpgradeTaskFSM::RecursiveGetSubFiles(const char *pszDir, const char *pszTrimStart,  list<CSimpleStringA>& retList)
@@ -3192,7 +3344,26 @@ bool CUpgradeTaskFSM::IsFileMatch(const char *pszFilter, const char *pszFileName
 bool CUpgradeTaskFSM::RecursiveCopyDir(const char *pszSourceDir, const char *pszDestDir,CSimpleStringA &strErrInfo)
 {
 	array_header_t *arr;
+#ifdef RVC_OS_WIN
+	if (!ExistsDirA(pszSourceDir))
+	{
+		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("source dir [%s] not exists: %d", pszSourceDir,GetLastError());
+		strErrInfo = CSimpleStringA::Format("source dir [%s] not exists: %d", pszSourceDir, GetLastError());
+		return false;
+	}
+
+	if (!ExistsDirA(pszDestDir))
+	{
+		if (!CreateDirRecursiveA(pszDestDir))
+		{
+			strErrInfo = CSimpleStringA::Format("create dir [%s] fail: %d", pszDestDir, GetLastError());
+			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("create dir fail: %s",strErrInfo.GetData());
+			return false;
+		}
 
+		//DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("create dir [%s] succ", pszDestDir);
+	}
+#else
 	if (!ExistsDirA(pszSourceDir))
 	{
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("source dir [%s] not exists: %d", pszSourceDir, errno);
@@ -3211,7 +3382,7 @@ bool CUpgradeTaskFSM::RecursiveCopyDir(const char *pszSourceDir, const char *psz
 
 		//DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("create dir [%s] succ", pszDestDir);
 	}
-
+#endif
 	arr = fileutil_get_sub_files_a(pszSourceDir);
 	if (arr)
 	{
@@ -3224,19 +3395,24 @@ bool CUpgradeTaskFSM::RecursiveCopyDir(const char *pszSourceDir, const char *psz
 			if (szDestFile[strlen(szDestFile) - 1] != SPLIT_SLASH)
 				strcat(szDestFile, SPLIT_SLASH_STR);
 			strcat(szDestFile, strrchr(file, SPLIT_SLASH) + 1);
+
 #ifdef RVC_OS_WIN
 			if (!CopyFileA(file, szDestFile, FALSE))
+			{
+				strErrInfo = CSimpleStringA::Format("copy file [%s] fail: %d", file, GetLastError());
+				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("copy file fail:%s",strErrInfo.GetData());
+				toolkit_array_free2(arr);
+				return false;
+			}
 #else
 			if (fileutil_copy_file(szDestFile, file)!=0)
-#endif
 			{
 				strErrInfo = CSimpleStringA::Format("copy file [%s] fail: %d", file, errno);
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("copy file fail:%s",strErrInfo.GetData());
 				toolkit_array_free2(arr);
 				return false;
 			}
-
-			
+#endif						
 		}
 		toolkit_array_free2(arr);
 	}
@@ -3256,12 +3432,21 @@ bool CUpgradeTaskFSM::RecursiveCopyDir(const char *pszSourceDir, const char *psz
 
 			if (!RecursiveCopyDir(dir, szDestSubDir,strErrInfo))
 			{
+#ifdef RVC_OS_WIN
+				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("copy dir [%s] fail: %d", dir, GetLastError());
+				if(strErrInfo.IsNullOrEmpty()){
+					strErrInfo = CSimpleStringA::Format("copy dir [%s] fail: %d", dir, GetLastError());
+				}
+				toolkit_array_free2(arr);
+				return false;
+#else
 				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("copy dir [%s] fail: %d", dir, errno);
 				if (strErrInfo.IsNullOrEmpty()) {
 					strErrInfo = CSimpleStringA::Format("copy dir [%s] fail: %d", dir, errno);
 				}
 				toolkit_array_free2(arr);
 				return false;
+#endif				
 			}
 
 			//DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("RecursiveCopyDir")("copy dir [%s] succ", dir);
@@ -3677,7 +3862,11 @@ ErrorCodeEnum CUpgradeTaskFSM::DeleteUnzipDir()
 	if (ExistsDirA(strUnzipDir.GetData()))
 	{
 		if(!RemoveDirRecursiveA(strUnzipDir.GetData())){
+#ifdef RVC_OS_WIN		
+			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DeleteUnzipDir")("DeleteUnzipDir fail , temp unzip dir [%s] fail,err=%d",strUnzipDir.GetData(),(int)GetLastError());
+#else
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DeleteUnzipDir")("DeleteUnzipDir fail , temp unzip dir [%s] fail,err=%d",strUnzipDir.GetData(), errno);
+#endif
 			return Error_Unexpect;
 		}else{
 			return Error_Succeed;
@@ -4396,7 +4585,10 @@ ErrorCodeEnum CUpgradeTaskFSM::NewSM3Folder(CSimpleStringA scanFilter,CSimpleStr
 				CSimpleStringA tempFileName = _GetFileName(scanFilter.GetData());
 				CSimpleStringA relativePath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s",replaceDir.GetData(),tempFileName.GetData());
 				//Dbg("scan file succ [%s]",relativePath.GetData());
+#ifdef RVC_OS_WIN
+#else
 				Sleep(100);//加入时间碎片
+#endif
 				m_fileSM3Map[relativePath] = strMD5Val;
 			}
 		}
@@ -4545,8 +4737,13 @@ bool CUpgradeTaskFSM::DownloadFileWrite(byte* content,long contentLen,const char
 	fclose(tempFp);
 
 	if(ret!=1){
+#ifdef RVC_OS_WIN
+		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadFileWrite")("DownloadFileWrite write file fail,ret = %d,errno = %d",ret,(int)GetLastError());
+		return false;
+#else
 		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI("DownloadFileWrite")("DownloadFileWrite write file fail,ret = %d,errno = %d",ret, errno);
 		return false;
+#endif		
 	}
 	return true;
 }

+ 4 - 0
Module/mod_UpgradeMgr/mod_UpgradeMgr.cpp

@@ -396,7 +396,11 @@ ErrorCodeEnum CUpgradeMgrEntity::testActive()
 
 	FILE* fp = fopen(strActiveFile.GetData(),"rb+");
 	if(fp==NULL){
+#ifdef RVC_OS_WIN
+		LogWarn(Severity_Middle, Error_Exception, ERR_WRAN_OPEN_ACTIVE_FAIL,CSimpleStringA::Format("open write active.txt fail,please edit active attribute, err=%d",(int)GetLastError()).GetData());
+#else
 		LogWarn(Severity_Middle, Error_Exception, ERR_WRAN_OPEN_ACTIVE_FAIL,CSimpleStringA::Format("open write active.txt fail,please edit active attribute, err=%d",errno).GetData());
+#endif	
 		return Error_Unexpect;
 	}
 	fclose(fp);

+ 7 - 0
Module/mod_UpgradeMgr/mod_UpgradeMgr.h

@@ -94,6 +94,7 @@ public:
 
 	virtual void Handle_RegistLocalPack(SpReqAnsContext<UpgradeMgrService_RegistLocalPack_Req, UpgradeMgrService_RegistLocalPack_Ans>::Pointer ctx)
 	{
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		ErrorCodeEnum rc = m_pEntity->RegistLocalPack(ctx->Req.strPackFile);
 		ctx->Answer(rc);
 	}
@@ -101,6 +102,7 @@ public:
 	virtual void Handle_RegistManualPack(SpReqAnsContext<UpgradeMgrService_RegistManualPack_Req, UpgradeMgrService_RegistManualPack_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_IsDownloading")("RegistManualPack received!");
 		DWORD dwRet = 0;
 		CSimpleStringA strErrmsg="RegistManualPack new UpgradeMgr is not deal with";
@@ -114,6 +116,7 @@ public:
 
 	virtual void Handle_CancelUpdate(SpReqAnsContext<UpgradeMgrService_CancelUpdate_Req, UpgradeMgrService_CancelUpdate_Ans>::Pointer ctx)
 	{
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_CancelUpdate")("CancelUpdate received!");
 		ErrorCodeEnum rc = m_pEntity->CancelUpdate(ctx->Req.strPackFile);
 		ctx->Answer(rc);
@@ -121,6 +124,7 @@ public:
 
 	virtual void Handle_RollbackUpdate(SpReqAnsContext<UpgradeMgrService_RollbackUpdate_Req, UpgradeMgrService_RollbackUpdate_Ans>::Pointer ctx)
 	{
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_RollbackUpdate")("RollbackUpdate received!");
 		auto rc = m_pEntity->RollbackUpdate(ctx->Req.strVersion);
 		ctx->Answer(rc);
@@ -128,6 +132,7 @@ public:
 
 	virtual void Handle_GetUpgradeState(SpReqAnsContext<UpgradeMgrService_GetUpgradeState_Req, UpgradeMgrService_GetUpgradeState_Ans>::Pointer ctx)
 	{
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_GetUpgradeState")("GetUpgradeState received!");
 		auto rc = m_pEntity->GetUpgradeState(ctx->Ans.bInstalling, ctx->Ans.strPackFile, ctx->Ans.strExecID,
 			ctx->Ans.cInstallState, ctx->Ans.bSysInstall, ctx->Ans.bLightPack, ctx->Ans.strNewVersion);
@@ -136,6 +141,7 @@ public:
 
 	virtual void Handle_SwitchUpgrade(SpReqAnsContext<UpgradeMgrService_SwitchUpgrade_Req, UpgradeMgrService_SwitchUpgrade_Ans>::Pointer ctx)
 	{
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_SwitchUpgrade")("SwitchUpgrade received!");
 		auto rc = m_pEntity->SwitchUpgrade(ctx->Req.strPackFile);
 		ctx->Answer(rc);
@@ -144,6 +150,7 @@ public:
 	virtual void Handle_GetManualPacks(SpReqAnsContext<UpgradeMgrService_GetManualPacks_Req, UpgradeMgrService_GetManualPacks_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
+		DbgToBeidou(ctx->link, __FUNCTION__)();
 		DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Handle_GetManualPacks")("GetManualPacks received!");
 		DWORD dwRet = 0;
 		CSimpleStringA strErrmsg= "GetManualPacks new UpgradeMgr is not deal with";