Abstract --Backup-dir checks so can be applied across Sync, Copy, Move
This commit is contained in:
committed by
Nick Craig-Wood
parent
6bae3595a8
commit
eea1b6de32
+6
-2
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/ncw/rclone/cmd"
|
||||
"github.com/ncw/rclone/fs/operations"
|
||||
"github.com/ncw/rclone/fs/sync"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -44,9 +45,12 @@ go there.
|
||||
`,
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
cmd.CheckArgs(2, 2, command, args)
|
||||
fsrc, fdst := cmd.NewFsSrcDst(args)
|
||||
fsrc, srcFileName, fdst := cmd.NewFsSrcFileDst(args)
|
||||
cmd.Run(true, true, command, func() error {
|
||||
return sync.Sync(context.Background(), fdst, fsrc, createEmptySrcDirs)
|
||||
if srcFileName == "" {
|
||||
return sync.Sync(context.Background(), fdst, fsrc, createEmptySrcDirs)
|
||||
}
|
||||
return operations.CopyFile(context.Background(), fdst, fsrc, srcFileName, srcFileName)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user