Skip to content

Commit

Permalink
修复校验文件问题
Browse files Browse the repository at this point in the history
  • Loading branch information
iikira committed Aug 31, 2018
1 parent df82928 commit e63018b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions internal/pcscommand/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ func RunDownload(paths []string, options *DownloadOptions) {

fmt.Fprintf(options.Out, "[%d] %s, %s, 重试 %d/%d\n", task.ID, errManifest, err, task.retry, task.MaxRetry)

switch err {
case ErrChecksumFailed:
// 删去旧的文件, 重新下载
rerr := os.Remove(task.savePath)
if rerr != nil {
fmt.Fprintf(options.Out, "[%d] 移除文件失败, %s\n", task.ID, rerr)
failedList = append(failedList, task.path)
return
}
}

// 未达到失败重试最大次数, 将任务推送到队列末尾
if task.retry < task.MaxRetry {
task.retry++
Expand Down Expand Up @@ -462,6 +473,7 @@ func RunDownload(paths []string, options *DownloadOptions) {
err = checkFileValid(task.savePath, task.downloadInfo)
if err != nil {
handleTaskErr(task, "检验文件有效性出错", err)
return
} else {
fmt.Fprintf(options.Out, "[%d] 检验文件有效性成功\n", task.ID)
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ func main() {
},
cli.BoolFlag{
Name: "nocheck",
Usage: "下载文件完成后不检测文件的有效性",
Usage: "下载文件完成后不校验文件",
},
cli.BoolFlag{
Name: "bg",
Expand Down

0 comments on commit e63018b

Please sign in to comment.