From 4e2b5389d75fbe245330a70adcf4911a63299d55 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 15 Oct 2020 11:48:06 +0100 Subject: [PATCH] check: make the error count match up in the log message Before this change we counted the final summary error as an error, producing confusing log messages like: Failed to check with 54 errors: last error was: 53 differences found This change marks the summary error as already being counted, so the error message becomes: Failed to check with 53 errors: last error was: 53 differences found This change also returns a listing failure in preference to a summary error. See: https://forum.rclone.org/t/slow-checksum-validation/19763/22 --- fs/operations/check.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/operations/check.go b/fs/operations/check.go index dc2f99c07..a1edc0f3d 100644 --- a/fs/operations/check.go +++ b/fs/operations/check.go @@ -11,6 +11,7 @@ import ( "github.com/pkg/errors" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/accounting" + "github.com/rclone/rclone/fs/fserrors" "github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/fs/march" "github.com/rclone/rclone/lib/readers" @@ -238,10 +239,16 @@ func CheckFn(ctx context.Context, opt *CheckOpt) error { if c.matches > 0 { fs.Logf(c.opt.Fdst, "%d matching files", c.matches) } - if c.differences > 0 { - return errors.Errorf("%d differences found", c.differences) + if err != nil { + return err } - return err + if c.differences > 0 { + // Return an already counted error so we don't double count this error too + err = fserrors.FsError(errors.Errorf("%d differences found", c.differences)) + fserrors.Count(err) + return err + } + return nil } // Check the files in fsrc and fdst according to Size and hash