| | |
| | | "mime/multipart" |
| | | "os" |
| | | "os/exec" |
| | | "path" |
| | | "strings" |
| | | "webserver/extend/config" |
| | | "webserver/extend/util" |
| | |
| | | if !util.CreateDirectory(configPatchPath) { |
| | | return false |
| | | } |
| | | index := strings.LastIndex(arg.Header.Filename, ".") |
| | | if index < 0 { |
| | | return false |
| | | } |
| | | subfix := arg.Header.Filename[index:] |
| | | |
| | | filenameWithSuffix := path.Base(arg.Header.Filename) |
| | | subfix := path.Ext(filenameWithSuffix) |
| | | MD5Str := arg.Identifier |
| | | logger.Debug("Identifier:",MD5Str) |
| | | fileTmpPath := configPatchPath + "/"+MD5Str |
| | |
| | | } else { |
| | | configPatchPath = "/opt/vasystem/patch" |
| | | } |
| | | index := strings.LastIndex(filename, ".") |
| | | if index < 0 { |
| | | return false,errors.New("非法的升级压缩包文件") |
| | | } |
| | | ext := filename[index:] |
| | | |
| | | filenameWithSuffix := path.Base(filename) |
| | | ext := path.Ext(filenameWithSuffix) |
| | | |
| | | zipFilePath := configPatchPath + "/"+identifier+ext |
| | | if util.Exists(zipFilePath) { |
| | | //校验md5 |
| | |
| | | return false,errors.New("获取升级压缩包md5失败") |
| | | } |
| | | if strMd5 == identifier { |
| | | if util.TarGzCheck(zipFilePath) { |
| | | if !updatePatch(identifier, ext) { |
| | | return false,errors.New("执行升级过程异常") |
| | | } |
| | | return true,nil |
| | | } else { |
| | | logger.Debug("not a valid zip file,path:",zipFilePath) |
| | | return false,errors.New("升级程序解压失败,请确定上传的补丁是zip格式") |
| | | if !updatePatch(identifier, ext) { |
| | | return false,errors.New("执行升级过程异常,请确定上传的补丁是tar.gz格式") |
| | | } |
| | | return true,nil |
| | | |
| | | } else { |
| | | logger.Debug("strMd5 is", strMd5,"identifier is",identifier,"not equal") |
| | | return false,errors.New("校验升级文件失败") |