Sfoglia il codice sorgente

Z991239-3139 #comment [mod_UpgradeMgr] 升级去分行化修复解压bug和给下载包赋权

Signed-Off-By: commit-hook
刘文涛80174520 3 anni fa
parent
commit
e46eeeb40f

+ 1 - 0
Module/mod_UpgradeMgr/CMakeLists.txt

@@ -63,6 +63,7 @@ target_link_directories(${MODULE_NAME} PRIVATE ${CONAN_LIB_DIRS_ZLIB})
 
 # 添加实体需要依赖的其他共享库(包括系统库):连接器包含的包
 set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_ALL_LIBS} ${CONAN_PKG_LIBS_JSONCPP})
+set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_ALL_LIBS} ${CONAN_PKG_LIBS_ZLIB})
 
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})  
 

+ 33 - 7
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -3779,14 +3779,19 @@ ErrorCodeEnum CUpgradeTaskFSM::UnzipPack(const char* unZipPackName)
 		}
 	}
 	// 创建临时解压目录
-	if (CreateDirA(strUnzipDir.GetData(), false)) {
-		// 创建临时解压目录
+	if (!CreateDirA(strUnzipDir.GetData(), false)) {
+		// 创建临时解压目录失败
 		Dbg("unzipPack is fail,create temp unzip dir [%s] fail,err=%d", strUnzipDir.GetData(), GetLastError());
 		return Error_Unexpect;
 	}
 
-	// 解压
+	if (changeFileAtt(strZipFile.GetData())!=0) {
+		//改变文件属性
+		Dbg("unzipPack is fail,changeFileAtt zip [%s] fail,err=%d", strZipFile.GetData(), GetLastError());
+		return Error_Unexpect;
+	}
 
+	// 解压
 	string zipFileStr = strZipFile.GetData();
 	string zipTempDir = strUnzipDir.GetData();
 
@@ -5134,6 +5139,27 @@ bool CUpgradeTaskFSM::isWork()
 
 }
 
+int CUpgradeTaskFSM::changeFileAtt(const char* path)
+	{
+		struct stat attr_of_del;
+		if (lstat(path, &attr_of_del) == 0)
+		{
+			//修改为775属性
+			mode_t f_attrib = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH;
+			if (chmod(path, f_attrib) != 0)
+			{
+				Dbg("set file attribute is fail,errno=%d, file=%s", errno, path);
+				return -1;
+			}
+			return 0;
+		}
+		else {
+			Dbg("get file attribute is fail,errno=%d, file=%s", errno, path);
+			return -1;
+		}
+
+	}
+
 void CUpgradeTaskFSM::OnStateTrans(int iSrcState, int iDstState)
 {
 	Dbg("trans from %s to %s", GetStateName(iSrcState), GetStateName(iDstState));
@@ -5585,7 +5611,7 @@ void CUpgradeTaskFSM::s3_on_entry()
 	ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(qTask);
 	if(rc!=Error_Succeed){
 		Dbg("s3 create QueryNewTask fail,wait 4 min retry ,err=%d",(int)rc);
-		ScheduleTimer(1, 4*60*1000);//等待4分钟后再次查询是否有新任务
+		ScheduleTimer(1, 1*60*1000);//等待4分钟后再次查询是否有新任务
 	}
 }
 
@@ -5613,7 +5639,7 @@ unsigned int CUpgradeTaskFSM::s3_on_event(FSMEvent* event)
 					m_queryNewTaskCount=0;
 				}
 				Dbg("QueryNewTask succ,no new task, wait 4 min retry");
-				ScheduleTimer(1, 4*60*1000);//等待4分钟后再次查询是否有新任务
+				ScheduleTimer(1, 1*60*1000);//等待4分钟后再次查询是否有新任务
 			}else{
 				//写入运行时文件
 				bool isWriteOk=false;
@@ -5659,7 +5685,7 @@ unsigned int CUpgradeTaskFSM::s3_on_event(FSMEvent* event)
 		}else{
 			//查询失败
 			Dbg("QueryNewTask fail,wait 4 min retry");
-			ScheduleTimer(1, 4*60*1000);//等待4分钟后再次查询是否有新任务
+			ScheduleTimer(1, 1*60*1000);//等待4分钟后再次查询是否有新任务
 		}
 	}
 	else if(event->iEvt == EVT_TIMER){
@@ -5670,7 +5696,7 @@ unsigned int CUpgradeTaskFSM::s3_on_event(FSMEvent* event)
 			ErrorCodeEnum rc = m_pEntity->GetFunction()->PostThreadPoolTask(nTask);
 			if(rc!=Error_Succeed){
 				Dbg("s3 create QueryNewTask fail,wait 4 min retry ,err=%d",(int)rc);
-				ScheduleTimer(1, 4*60*1000);//等待4分钟后再次查询是否有新任务
+				ScheduleTimer(1, 1*60*1000);//等待4分钟后再次查询是否有新任务
 			}
 		}
 	}

+ 3 - 0
Module/mod_UpgradeMgr/UpgradeTaskFSM.h

@@ -364,6 +364,9 @@ public:
 
 	bool isWork();
 
+	int changeFileAtt(const char* path);
+
+
 private:
 	virtual void OnStateTrans(int iSrcState, int iDstState);
 	virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName);

+ 1 - 1
Module/mod_UpgradeMgr/XUnZipZilb.cpp

@@ -20,7 +20,7 @@
 
 int UnZipToDir(string zipFileName, string destDirPath)
 {
-	//	Dbg("zipFileName %s destDirPath %s", zipFileName.c_str(), destDirPath.c_str());
+	Dbg("zipFileName %s destDirPath %s", zipFileName.c_str(), destDirPath.c_str());
 	unzFile zfile = unzOpen(zipFileName.c_str());
 	if (zfile == NULL)
 	{