Skip to content

Commit

Permalink
Merge pull request cupcakearmy#157 from jjromannet/fix-copy-config-fi…
Browse files Browse the repository at this point in the history
…le-before-overriding

Make a copy of config before overriding it
  • Loading branch information
cupcakearmy committed Feb 13, 2022
2 parents 27758a0 + 65ba1f6 commit 8e1fe6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (c *Config) SaveConfig() error {
if err := CopyFile(file, file+".old"); err != nil {
return err
}
colors.Secondary.Println("Saved a backup copy of your file next the the original.")
colors.Secondary.Println("Saved a backup copy of your file next to the original.")

viper.Set("backends", c.Backends)
viper.Set("locations", c.Locations)
Expand Down
4 changes: 2 additions & 2 deletions internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func ExecuteResticCommand(options ExecuteOptions, args ...string) (string, error
}

func CopyFile(from, to string) error {
original, err := os.Open("original.txt")
original, err := os.Open(from)
if err != nil {
return nil
}
defer original.Close()

new, err := os.Create("new.txt")
new, err := os.Create(to)
if err != nil {
return nil
}
Expand Down

0 comments on commit 8e1fe6a

Please sign in to comment.