From 800d519d20f0c8cd9b6746053dc9f1f0bf0f5d04 Mon Sep 17 00:00:00 2001 From: Baptiste Ducatel Date: Wed, 13 Jul 2022 10:40:35 +0200 Subject: [PATCH] Fix backup of a single file --- actions/backup.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/actions/backup.go b/actions/backup.go index 40e6b42..063a1d6 100644 --- a/actions/backup.go +++ b/actions/backup.go @@ -80,6 +80,9 @@ func BackupActionHandler(ctx domain.ExecutionContext, backupFilesOpt *bool, back // prepare a walk function to handle the whole hierarchy walkFunc := func(filepath string, info os.FileInfo, err error) error { + if err != nil { + return fmt.Errorf("%s file or directory not found \n%s\n", filepath, err) + } target := path.Join(filesDir, filepath) // just create the directory @@ -94,15 +97,6 @@ func BackupActionHandler(ctx domain.ExecutionContext, backupFilesOpt *bool, back } for _, file := range config.Get().BackupConfig.Files { - fmt.Println(file) - fileInfo, err := os.Stat(file) - if err != nil { - return fmt.Errorf("%s file or directory not found \n%s\n", file, err) - } - if !fileInfo.IsDir() { - return fmt.Errorf("%s is not a directory \n", file) - } - err = filepath.Walk(file, walkFunc) if err != nil { return fmt.Errorf("Unable to walk into %s\n%s\n", file, err)