diff --git a/internal/pcscommand/download.go b/internal/pcscommand/download.go index c4500ce0..aeeb0635 100644 --- a/internal/pcscommand/download.go +++ b/internal/pcscommand/download.go @@ -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++ @@ -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) } diff --git a/main.go b/main.go index f158c348..62fe6d39 100644 --- a/main.go +++ b/main.go @@ -1062,7 +1062,7 @@ func main() { }, cli.BoolFlag{ Name: "nocheck", - Usage: "下载文件完成后不检测文件的有效性", + Usage: "下载文件完成后不校验文件", }, cli.BoolFlag{ Name: "bg",