Abstract --Backup-dir checks so can be applied across Sync, Copy, Move

This commit is contained in:
yparitcher
2019-07-01 10:46:26 +01:00
committed by Nick Craig-Wood
parent 6bae3595a8
commit eea1b6de32
3 changed files with 42 additions and 34 deletions
+6 -2
View File
@@ -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)
})
},
}