| | |
| | | return true, nil |
| | | } |
| | | |
| | | func (sv SdkInstallService) ShowInstallInfo(identifier string) (bool, map[string]interface{}) { |
| | | func (sv SdkInstallService) ShowInstallInfo(identifier string, filename string) (bool, map[string]interface{}, error) { |
| | | configPatchPath := "" |
| | | if config.Server.PatchPath != "" { |
| | | configPatchPath = config.Server.PatchPath |
| | |
| | | configPatchPath = "../patch" |
| | | } |
| | | unPackTargetPath := configPatchPath+"/"+identifier+"_basic/" |
| | | isValid := false |
| | | defer func() { |
| | | if !isValid { |
| | | filenameWithSuffix := path.Base(filename) |
| | | ext := path.Ext(filenameWithSuffix) |
| | | unPackFilePath := configPatchPath+"/"+identifier+ext |
| | | md5DirPath := configPatchPath+"/"+identifier |
| | | |
| | | if util.Exists(unPackTargetPath) { |
| | | os.RemoveAll(unPackTargetPath) |
| | | } |
| | | if util.Exists(unPackFilePath) { |
| | | os.RemoveAll(unPackFilePath) |
| | | } |
| | | if util.DirExists(md5DirPath) { |
| | | go os.RemoveAll(md5DirPath) |
| | | } |
| | | |
| | | } |
| | | }() |
| | | if util.Exists(unPackTargetPath) { |
| | | targetFileName := "" |
| | | err := filepath.Walk(unPackTargetPath, func(path string, f os.FileInfo, err error) error { |
| | |
| | | return nil |
| | | }) |
| | | if err != nil { |
| | | return false, nil |
| | | return isValid, nil, errors.New("非法的安装包") |
| | | } else { |
| | | unPackPath := unPackTargetPath + targetFileName +"/" |
| | | //解压完成,获取安装包中的文件,开始安装 |
| | |
| | | "sdkName": ins.ProductName, |
| | | "installVersion": ins.InstallVersion, |
| | | "installContent": ins.InstallContent, |
| | | } |
| | | }, nil |
| | | } else { |
| | | return false, nil |
| | | return false, nil, errors.New("非法的安装包") |
| | | } |
| | | } else { |
| | | return false, nil |
| | | return false, nil, errors.New("非法的安装包") |
| | | } |
| | | } else { |
| | | return false, nil |
| | | return false, nil, errors.New("非法的安装包") |
| | | } |
| | | } |
| | | } else { |
| | | return false, nil |
| | | return isValid, nil, errors.New("安装包已不存在") |
| | | } |
| | | } |
| | | |
| | |
| | | sdkVersion, ok := sm["version"] |
| | | if ok { //有版本号 |
| | | vStr := sdkVersion.(string) |
| | | if shouldVersionBeUpgrade(vStr, skd.Def.Version) { |
| | | if shouldVersionBeUpgrade(vStr, skd.Def.Version) { //比对版本号确定是否需要安装 |
| | | nInsM[skd.Def.SdkType] = skd.Def.SdkType |
| | | aInsM[skd.Def.Id] = skd.Def.Id |
| | | } |