| | |
| | | } |
| | | defer file.Close() |
| | | writer := bufio.NewWriter(file) |
| | | chunkData := make([]byte, arg.CurrentChunkSize) |
| | | chunkData := make([]byte, arg.Header.Size) |
| | | n, err := (*arg.File).ReadAt(chunkData, 0) |
| | | if n ==0 || err !=nil { |
| | | logger.Debug("read chunkData err:",err,"n:",n) |
| | | return false |
| | | } |
| | | logger.Debug("read chunkData len:",n) |
| | | nn, err2 := writer.Write(chunkData) |
| | | if nn ==0 || err2 !=nil { |
| | | logger.Debug("write chunkData err:",err2,"nn:",nn) |
| | | return false |
| | | } |
| | | logger.Debug("write chunkData len:",nn) |
| | | if err = writer.Flush(); err != nil { |
| | | logger.Debug("write flush err:",err) |
| | | } |
| | | isComplete := false |
| | | dirFiles, _ := ioutil.ReadDir(fileTmpPath) |
| | | if dirFiles != nil && len(dirFiles) == arg.TotalChunks { |
| | |
| | | //判断更新包里是否有补丁脚本,如果有则执行,否则执行updatePatch.sh |
| | | updateCmd := fmt.Sprintf("./updatePatch.sh %s %s %s &",unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | if util.Exists(unZipPath+"upgrade.sh") { |
| | | updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s &",unZipPath,unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | updateCmd = fmt.Sprintf("%supgrade.sh %s %s %s",unZipPath,unZipPath,zipFilePath,configPatchPath+"/"+identifier) |
| | | } |
| | | //2.更新系统 |
| | | b,err := ExecCmd(updateCmd) |