From 88c509e3e9c301d72e0aabf9abd3c7c13344b090 Mon Sep 17 00:00:00 2001 From: DRON-666 <64691982+DRON-666@users.noreply.github.com> Date: Tue, 10 Nov 2020 06:48:05 +0300 Subject: [PATCH] vss: Change `ErrorHandler` signature We don't need `error` here: the only existing implementation of `ErrorHandler` always call `Backup.Error` and all implementations of `Backup.Error` always return nil. --- cmd/restic/cmd_backup.go | 4 ++-- internal/fs/fs_local_vss.go | 6 +++--- internal/fs/fs_local_vss_test.go | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 5329a928c..19b96e9b0 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -556,8 +556,8 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter return err } - errorHandler := func(item string, err error) error { - return progressReporter.Error(item, err) + errorHandler := func(item string, err error) { + _ = progressReporter.Error(item, err) } messageHandler := func(msg string, args ...interface{}) { diff --git a/internal/fs/fs_local_vss.go b/internal/fs/fs_local_vss.go index 0e73092f2..230e14a1f 100644 --- a/internal/fs/fs_local_vss.go +++ b/internal/fs/fs_local_vss.go @@ -43,8 +43,8 @@ func ParseVSSConfig(o options.Options) (VSSConfig, error) { return cfg, nil } -// ErrorHandler is used to report errors via callback -type ErrorHandler func(item string, err error) error +// ErrorHandler is used to report errors via callback. +type ErrorHandler func(item string, err error) // MessageHandler is used to report errors/messages via callbacks. type MessageHandler func(msg string, args ...interface{}) @@ -114,7 +114,7 @@ func (fs *LocalVss) DeleteSnapshots() { for volumeName, snapshot := range fs.snapshots { if err := snapshot.Delete(); err != nil { - _ = fs.msgError(volumeName, errors.Errorf("failed to delete VSS snapshot: %s", err)) + fs.msgError(volumeName, errors.Errorf("failed to delete VSS snapshot: %s", err)) activeSnapshots[volumeName] = snapshot } } diff --git a/internal/fs/fs_local_vss_test.go b/internal/fs/fs_local_vss_test.go index ce07fee3c..6beb35b98 100644 --- a/internal/fs/fs_local_vss_test.go +++ b/internal/fs/fs_local_vss_test.go @@ -88,10 +88,8 @@ func TestVSSConfig(t *testing.T) { t.Fatal(err) } - errorHandler := func(item string, err error) error { + errorHandler := func(item string, err error) { t.Fatalf("unexpected error (%v)", err) - - return nil } messageHandler := func(msg string, args ...interface{}) { t.Fatalf("unexpected message (%s)", fmt.Sprintf(msg, args)) @@ -181,10 +179,8 @@ func TestParseMountPoints(t *testing.T) { } var log []string - errorHandler := func(item string, err error) error { + errorHandler := func(item string, err error) { log = append(log, strings.TrimSpace(err.Error())) - - return nil } messageHandler := func(msg string, args ...interface{}) { t.Fatalf("unexpected message (%s)", fmt.Sprintf(msg, args))