|
@@ -329,30 +329,6 @@ ErrorCodeEnum SpEntityPrivilege::Reboot(RebootTriggerEnum eTriggerReason,RebootW
|
|
|
return Error;
|
|
|
}
|
|
|
|
|
|
-bool SpEntityPrivilege::WriteInstallLog(const char *pszPackName, const char *pszLogText)
|
|
|
-{
|
|
|
- auto env = sp_get_env();
|
|
|
-
|
|
|
- // 创建安装包日志文件
|
|
|
- CSimpleStringA strInstallLogDir = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "InstallLog", env->dir->root_runinfo_path);
|
|
|
- if (!ExistsDirA(strInstallLogDir))
|
|
|
- CreateDirA(strInstallLogDir, TRUE);
|
|
|
-
|
|
|
- // 写安装包日志
|
|
|
- CSimpleStringA strInstallLog = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s.log", (const char*)strInstallLogDir, pszPackName);
|
|
|
- FILE *pInstallLog = fopen(strInstallLog, "a+");
|
|
|
- if (pInstallLog == NULL)
|
|
|
- {
|
|
|
- LogError(Severity_Low, Error_Unexpect, 0, CSimpleStringA::Format("open install log file [%s] to write fail", pszPackName));
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- fprintf_s(pInstallLog, "[%s] %s\r\n", (const char*)CSmallDateTime::GetNow().ToTimeString(), pszLogText);
|
|
|
- fflush(pInstallLog);
|
|
|
- fclose(pInstallLog);
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
bool SpEntityPrivilege::RecursiveCopyDir(const char *pszSourceDir, const char *pszDestDir, CSimpleStringA& strErrInfo)
|
|
|
{
|
|
|
array_header_t *arr;
|
|
@@ -428,7 +404,7 @@ bool SpEntityPrivilege::RecursiveCopyDir(const char *pszSourceDir, const char *p
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-ErrorCodeEnum SpEntityPrivilege::UpdateActiveTxt(const char* strActiveFilePath, const char* toWriteVersionStr, bool toCheck)
|
|
|
+ErrorCodeEnum SpEntityPrivilege::UpdateVerTxt(const char* strActiveFilePath, const char* toWriteVersionStr, bool toCheck)
|
|
|
{
|
|
|
HANDLE hFile = ::CreateFileA(strActiveFilePath, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
BOOL bSetSucc = FALSE;
|
|
@@ -999,6 +975,50 @@ ErrorCodeEnum SpEntityPrivilege::GetVTMErrMsgArr(CAutoArray<CSimpleStringA>& str
|
|
|
}
|
|
|
|
|
|
|
|
|
+ErrorCodeEnum SpEntityPrivilege::RewriteDepVersion(const CSimpleStringA& strVersion, bool bRefresh)
|
|
|
+{
|
|
|
+ ErrorCodeEnum rc(Error_Succeed);
|
|
|
+ auto dir = sp_get_env()->dir;
|
|
|
+ auto cfg = sp_get_env()->cfg;
|
|
|
+
|
|
|
+ if (dir == NULL)
|
|
|
+ return Error_Null;
|
|
|
+
|
|
|
+ if (strVersion.IsNullOrEmpty())
|
|
|
+ return Error_Param;
|
|
|
+
|
|
|
+ CSimpleStringA strOldVer(true);
|
|
|
+ rc = GetRunningDepVersion(strOldVer);
|
|
|
+ if (rc == Error_Succeed && !strOldVer.IsNullOrEmpty() && strOldVer.Compare(strVersion) == 0) {
|
|
|
+ return Error_AlreadyExist;
|
|
|
+ }
|
|
|
+
|
|
|
+ char path[MAX_PATH] = {'\0'};
|
|
|
+ rc = (ErrorCodeEnum)sp_dir_get_path(dir, SP_DIR_DEPVER_TXT, NULL, path, MAX_PATH);
|
|
|
+ if (rc != 0) {
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("get dep ver txt failed!");
|
|
|
+ return rc;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("path:%s", path);
|
|
|
+ }
|
|
|
+
|
|
|
+ rc = UpdateVerTxt(path, strVersion, true);
|
|
|
+ if (rc == Error_Succeed && bRefresh) {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to refresh...");
|
|
|
+ rc = (ErrorCodeEnum)sp_dir_refresh_dep_path(dir);
|
|
|
+ if (rc == Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to send fresh post");
|
|
|
+ iobuffer_t* pkt = iobuffer_create(-1, -1);
|
|
|
+ rc = PostInfoShell(SHELL_CMD_INFO_REFRESH_ENV, &pkt);
|
|
|
+ if (pkt)
|
|
|
+ iobuffer_dec_ref(pkt);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("send fresh post return %s", SpStrError(rc));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rc;
|
|
|
+}
|
|
|
+
|
|
|
ErrorCodeEnum SpEntityPrivilege::TryUpdateToken(CSimpleString& oldToken, CSimpleString& newToken)
|
|
|
{
|
|
|
char t_oldToken[MAX_PATH] = "", t_newToken[MAX_PATH] = "";
|