|
@@ -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;
|
|
|
}
|