Check return value of errors for config encrypt

This commit is contained in:
maggie0002 2022-07-22 14:46:04 +02:00
parent b0506a35e7
commit 99a4938d3b
2 changed files with 14 additions and 4 deletions

View File

@ -69,15 +69,22 @@ var configEncrypt = &cobra.Command{
pass your password directly as an argument. After encryption you will be
asked to enter a password when using Rclone. Passwords are not recoverable.
`,
Run: func(command *cobra.Command, args []string) {
RunE: func(command *cobra.Command, args []string) error {
if len(args) == 0 {
passwd := config.ChangePassword("NEW configuration")
config.SetConfigPassword(passwd)
err := config.SetConfigPassword(passwd)
if err != nil {
return err
}
} else {
cmd.CheckArgs(1, 1, command, args)
config.SetConfigPassword(args[0])
err := config.SetConfigPassword(args[0])
if err != nil {
return err
}
}
config.SaveConfig()
return nil
},
}

View File

@ -79,7 +79,10 @@ func rcEncrypt(ctx context.Context, in rc.Params) (out rc.Params, err error) {
"error": "password paramater not supplied",
}
} else {
SetConfigPassword(passwd)
err := SetConfigPassword(passwd)
if err != nil {
return nil, err
}
SaveConfig()
out = nil
}