From e2300fe21a2152746d37807756a40d0ad3d207c7 Mon Sep 17 00:00:00 2001 From: Milos Zivkovic Date: Tue, 10 Oct 2023 16:13:45 +0200 Subject: [PATCH] Improve stat error for recover --- cmd/restore.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/restore.go b/cmd/restore.go index 08153b3..59006a2 100644 --- a/cmd/restore.go +++ b/cmd/restore.go @@ -16,7 +16,10 @@ import ( "go.uber.org/zap" ) -var errInvalidInputPath = errors.New("invalid file input path") +var ( + errInvalidInputPath = errors.New("invalid file input path") + errInvalidFileSource = errors.New("invalid input file source") +) // restoreCfg is the restore command configuration type restoreCfg struct { @@ -86,10 +89,10 @@ func (c *restoreCfg) exec(ctx context.Context, _ []string) error { return errInvalidInputPath } - // Make sure the output file can be overwritten, if it exists + // Make sure the input file exists if _, err := os.Stat(c.inputPath); err != nil { - // File already exists, and the overwrite flag is not set - return errOutputFileExists + // Unable to verify input file existence + return fmt.Errorf("%w, %w", errInvalidFileSource, err) } // Set up the client