mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 23:22:08 +01:00
deletefile: return error code 4 if file does not exist
Before this change `rclone deletefile` would return error code 1 if the file it was trying to delete does not exist. Rclone can't actually tell at this point whether the file doesn't exist or what you tried to delete is a directory, but it seems more logical to return error code 4 "object not found" here. See: https://forum.rclone.org/t/rclone-deletefile-cmd-return-exit-code-1-when-file-not-found-in-remote-why-1-and-not-exit-code-4/
This commit is contained in:
parent
e25e9fbf22
commit
93d3ae04c7
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/operations"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@ -27,12 +28,12 @@ it will always be removed.
|
||||
},
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
cmd.CheckArgs(1, 1, command, args)
|
||||
fs, fileName := cmd.NewFsFile(args[0])
|
||||
f, fileName := cmd.NewFsFile(args[0])
|
||||
cmd.Run(true, false, command, func() error {
|
||||
if fileName == "" {
|
||||
return fmt.Errorf("%s is a directory or doesn't exist", args[0])
|
||||
return fmt.Errorf("%s is a directory or doesn't exist: %w", args[0], fs.ErrorObjectNotFound)
|
||||
}
|
||||
fileObj, err := fs.NewObject(context.Background(), fileName)
|
||||
fileObj, err := f.NewObject(context.Background(), fileName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user