Эх сурвалжийг харах

#IQRV #comment [Module] mod_UpgradeRun 合并

gifur 4 жил өмнө
parent
commit
c654af3a4a

+ 33 - 11
Module/mod_UpgradeRun/UpgradeRunFSM.cpp

@@ -1301,12 +1301,16 @@ struct SysPackInstallTask : ITaskSp
 
 		Dbg("end install sys pack: [%s], result: %s(%d)", (const char*)m_strSysPackName, (const char*)strErrMsg, rc);
 		
-		((CUpgradeRunEntity*)pEntity)->BroadcastUpgradeDoneEvent(e);			
+				
 
 		// 删除临时解压目录
 		m_pFSM->DeleteUnzipDir();//先删除临时目录,再发送Event_EndUpgrade,否则m_strInstallPack被清空后assert(!m_strInstallPack.IsNullOrEmpty())会报异常
 
-		m_pFSM->PostEventFIFO(new FSMEvent(CUpgradeRunFSM::Event_EndUpgrade));		
+		m_pFSM->PostEventFIFO(new FSMEvent(CUpgradeRunFSM::Event_EndUpgrade));	
+
+		Sleep(2000);
+
+		((CUpgradeRunEntity*)pEntity)->BroadcastUpgradeDoneEvent(e);	//modify by lwt 20210207,全部处理完再发事件,否则会导致UpgradeRun和UpgradeMgr两个状态机不同步
 	}
 };
 
@@ -1534,15 +1538,33 @@ ErrorCodeEnum CUpgradeRunFSM::InstallPack(bool &bSysInstall, bool &bLightPack, C
 				}
 				else
 				{
-					int nCopyMode = inifile_read_int(strConfigPath, GetFileName(file), "CopyMode", 3);
-				
-					rc = pPrivFunc->CopyFileToNewVersion(file, nCopyMode);
-					Dbg("copy file [%s] to new version %s", (const char*)file, rc == Error_Succeed ? "succeed" : "fail");				
-
-					if (rc != Error_Succeed)
-					{
-						strErrMsg = CSimpleStringA::Format("拷贝文件[%s]失败", (const char*)file);
-						return rc;
+					//判断绝对文件名是否存在,因存在智能对比,故此文件不一定存在
+					//Dbg("install file is %s",file.GetData());
+					CSimpleStringA strDownloadsPath;
+					ErrorCodeEnum ece =  m_pEntity->GetFunction()->GetPath("Downloads",  strDownloadsPath);
+					if(ece != Error_Succeed){
+						Dbg("InstallPack fail ,get Downloads path is fail ,copy file [%s] fail",file.GetData());
+						strErrMsg = CSimpleStringA::Format("拷贝文件[%s]失败", file.GetData());
+						return ece;
+					}
+					CSimpleStringA strUnzipPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strDownloadsPath.GetData(),  m_strInstallPack.GetData());
+					//Dbg("strUnzipPath is %s",strUnzipPath.GetData());
+					if (strUnzipPath.IsEndWith(".zip") || strUnzipPath.IsEndWith(".cab")){
+						strUnzipPath = strUnzipPath.SubString(0, strUnzipPath.GetLength()-4);
+					}
+					CSimpleStringA strSourceFile = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strUnzipPath.GetData(), file.GetData());
+					//Dbg("strSourceFile is %s",strSourceFile.GetData());
+					if(ExistsFileA(strSourceFile.GetData())){
+						//int nCopyMode = inifile_read_int(strConfigPath, GetFileName(file), "CopyMode", 3);
+						rc = pPrivFunc->CopyFileToNewVersion(file.GetData(), 3);
+						Dbg("copy file [%s] to new version %s", file.GetData(), rc == Error_Succeed ? "succeed" : "fail");
+						if (rc != Error_Succeed)
+						{
+							strErrMsg = CSimpleStringA::Format("拷贝文件[%s]失败", file.GetData());
+							return rc;
+						}
+					}else{
+						Dbg("file [%s] is not exist ,ignore copy to new version ",file.GetData());
 					}
 				}
 			}