From f6c9d2beeab23eaa7b0e6effaacbab23b536d99a Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Tue, 7 Jun 2022 09:36:42 +0700 Subject: [PATCH] downloader torrent_hashes --verify: 1 error line per file #4386 --- cmd/downloader/downloader/util.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/downloader/downloader/util.go b/cmd/downloader/downloader/util.go index ef896335b..c31278be8 100644 --- a/cmd/downloader/downloader/util.go +++ b/cmd/downloader/downloader/util.go @@ -347,6 +347,8 @@ func AddTorrentFile(ctx context.Context, torrentFilePath string, torrentClient * return t, nil } +var ErrSkip = fmt.Errorf("skip") + func VerifyDtaFiles(ctx context.Context, snapDir string) error { logEvery := time.NewTicker(5 * time.Second) defer logEvery.Stop() @@ -379,12 +381,12 @@ func VerifyDtaFiles(ctx context.Context, snapDir string) error { return err } - err = verifyTorrent(&info, snapDir, func(i int, good bool) error { + if err = verifyTorrent(&info, snapDir, func(i int, good bool) error { j++ if !good { failsAmount++ log.Error("[Snapshots] Verify hash mismatch", "at piece", i, "file", info.Name) - return nil + return ErrSkip } select { case <-logEvery.C: @@ -394,8 +396,10 @@ func VerifyDtaFiles(ctx context.Context, snapDir string) error { default: } return nil - }) - if err != nil { + }); err != nil { + if errors.Is(ErrSkip, err) { + continue + } return err } }