From e63018bcc7a572175ddc6c7ac1ed6f53e8da8bd0 Mon Sep 17 00:00:00 2001 From: iikira <2571583272@qq.com> Date: Fri, 31 Aug 2018 22:47:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=A1=E9=AA=8C=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pcscommand/download.go | 12 ++++++++++++ main.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) 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",