File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
_ "github.com/ncw/rclone/cmd/dbhashsum"
20
20
_ "github.com/ncw/rclone/cmd/dedupe"
21
21
_ "github.com/ncw/rclone/cmd/delete"
22
+ _ "github.com/ncw/rclone/cmd/deletefile"
22
23
_ "github.com/ncw/rclone/cmd/genautocomplete"
23
24
_ "github.com/ncw/rclone/cmd/gendocs"
24
25
_ "github.com/ncw/rclone/cmd/hashsum"
Original file line number Diff line number Diff line change
1
+ package deletefile
2
+
3
+ import (
4
+ "github.com/ncw/rclone/cmd"
5
+ "github.com/ncw/rclone/fs/operations"
6
+
7
+ "github.com/pkg/errors"
8
+ "github.com/spf13/cobra"
9
+ )
10
+
11
+ func init () {
12
+ cmd .Root .AddCommand (commandDefintion )
13
+ }
14
+
15
+ var commandDefintion = & cobra.Command {
16
+ Use : "deletefile remote:path" ,
17
+ Short : `Remove a single file path from remote.` ,
18
+ Long : `
19
+ Remove a single file path from remote. Unlike ` + "`" + `delete` + "`" + ` it cannot be used to
20
+ remove a directory and it doesn't obey include/exclude filters - if the specified file exists,
21
+ it will always be removed.
22
+ ` ,
23
+ Run : func (command * cobra.Command , args []string ) {
24
+ cmd .CheckArgs (1 , 1 , command , args )
25
+ fs , fileName := cmd .NewFsFile (args [0 ])
26
+ cmd .Run (true , false , command , func () error {
27
+ if fileName == "" {
28
+ return errors .Errorf ("%s is a directory or doesn't exist" , args [0 ])
29
+ }
30
+ fileObj , err := fs .NewObject (fileName )
31
+ if err != nil {
32
+ return err
33
+ }
34
+ return operations .DeleteFile (fileObj )
35
+ })
36
+ },
37
+ }
You can’t perform that action at this time.
0 commit comments