From 6133ad886bdb09157e15064a1baf3b531e938e24 Mon Sep 17 00:00:00 2001 From: wanghui Date: Mon, 18 Nov 2019 10:58:21 +0800 Subject: [PATCH] add checkfile after dofetch and remove failed download file --- build/paramfetch.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build/paramfetch.go b/build/paramfetch.go index b690a7d74..dba8171d7 100644 --- a/build/paramfetch.go +++ b/build/paramfetch.go @@ -87,7 +87,16 @@ func (ft *fetch) maybeFetchAsync(name string, info paramFile) { defer ft.fetchLk.Unlock() if err := doFetch(path, info); err != nil { - ft.errs = append(ft.errs, xerrors.Errorf("fetching file %s: %w", path, err)) + ft.errs = append(ft.errs, xerrors.Errorf("fetching file %s success: %w", path, err)) + return + } + err = ft.checkFile(path, info) + if err != nil { + ft.errs = append(ft.errs, xerrors.Errorf("fetching file %s failed: %w", path, err)) + err := os.Remove(path) + if err != nil { + ft.errs = append(ft.errs, xerrors.Errorf("remove file %s failed: %w", path, err)) + } } }() }