Commit 7e1b435e authored by szh's avatar szh

pai下载更新

parent bebe8928
...@@ -12,7 +12,7 @@ const ( ...@@ -12,7 +12,7 @@ const (
DOWNLOAD_ERROR = 5005 DOWNLOAD_ERROR = 5005
TAR_XVF_ERROR = 5006 TAR_XVF_ERROR = 5006
CP_ERROR = 5007 CP_ERROR = 5007
RM_ERROR = 5008
ERROR_EXIST_TAG = 10001 ERROR_EXIST_TAG = 10001
ERROR_EXIST_TAG_FAIL = 10002 ERROR_EXIST_TAG_FAIL = 10002
ERROR_NOT_EXIST_TAG = 10003 ERROR_NOT_EXIST_TAG = 10003
......
...@@ -7,6 +7,7 @@ var MsgFlags = map[int]string{ ...@@ -7,6 +7,7 @@ var MsgFlags = map[int]string{
DOWNLOAD_ERROR: "下载出错", DOWNLOAD_ERROR: "下载出错",
TAR_XVF_ERROR: "解压文件出错", TAR_XVF_ERROR: "解压文件出错",
CP_ERROR: "拷贝文件出错", CP_ERROR: "拷贝文件出错",
RM_ERROR: "删除文件出错",
ERROR_EXIST_TAG: "已存在该标签名称", ERROR_EXIST_TAG: "已存在该标签名称",
ERROR_EXIST_TAG_FAIL: "获取已存在标签失败", ERROR_EXIST_TAG_FAIL: "获取已存在标签失败",
ERROR_NOT_EXIST_TAG: "该标签不存在", ERROR_NOT_EXIST_TAG: "该标签不存在",
......
...@@ -104,7 +104,7 @@ func UpdatePai(c *gin.Context) { ...@@ -104,7 +104,7 @@ func UpdatePai(c *gin.Context) {
return return
} }
//替换原执行文件 //替换原执行文件
replace := exec.Command("cp",setting.Chain33Pai.DownloadDir+"/"+setting.Chain33Pai.Name,setting.Chain33Pai.Name) replace := exec.Command("mv",setting.Chain33Pai.DownloadDir+"/"+setting.Chain33Pai.Name,setting.Chain33Pai.Name)
err = replace.Start() err = replace.Start()
if err != nil { if err != nil {
appG.Response(http.StatusOK, e.CP_ERROR, nil) appG.Response(http.StatusOK, e.CP_ERROR, nil)
...@@ -117,5 +117,18 @@ func UpdatePai(c *gin.Context) { ...@@ -117,5 +117,18 @@ func UpdatePai(c *gin.Context) {
} }
//对比配置文件 比较麻烦 //对比配置文件 比较麻烦
//删除temp文件夹
//替换原执行文件
remove := exec.Command("rm","-rf",setting.Chain33Pai.DownloadDir,name)
err = remove.Start()
if err != nil {
appG.Response(http.StatusOK, e.RM_ERROR, nil)
return
}
err = remove.Wait()
if err != nil {
appG.Response(http.StatusOK, e.RM_ERROR, nil)
return
}
appG.Response(http.StatusOK, e.SUCCESS, nil) appG.Response(http.StatusOK, e.SUCCESS, nil)
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment