diff --git a/cmd/copy/copy.go b/cmd/copy/copy.go index a102aa64e..1812d4be0 100644 --- a/cmd/copy/copy.go +++ b/cmd/copy/copy.go @@ -3,13 +3,14 @@ package copy import ( "context" + "strings" + "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/operations" "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/fs/sync" "github.com/spf13/cobra" - "strings" ) var ( diff --git a/cmd/copyto/copyto.go b/cmd/copyto/copyto.go index 441268a67..58c825865 100644 --- a/cmd/copyto/copyto.go +++ b/cmd/copyto/copyto.go @@ -3,10 +3,10 @@ package copyto import ( "context" - "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs/operations" + "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/fs/sync" "github.com/spf13/cobra" ) diff --git a/cmd/move/move.go b/cmd/move/move.go index 72ba543e1..088f0d876 100644 --- a/cmd/move/move.go +++ b/cmd/move/move.go @@ -3,12 +3,12 @@ package move import ( "context" - "github.com/rclone/rclone/fs/operations/operationsflags" "strings" "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/operations" + "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/fs/sync" "github.com/spf13/cobra" ) @@ -92,9 +92,9 @@ for more info. } if srcFileName == "" { - return sync.MoveDir(context.Background(), fdst, fsrc, deleteEmptySrcDirs, createEmptySrcDirs) + return sync.MoveDir(ctx, fdst, fsrc, deleteEmptySrcDirs, createEmptySrcDirs) } - return operations.MoveFile(context.Background(), fdst, fsrc, srcFileName, srcFileName) + return operations.MoveFile(ctx, fdst, fsrc, srcFileName, srcFileName) }) }, } diff --git a/cmd/moveto/moveto.go b/cmd/moveto/moveto.go index 7a90b20b1..702cb3cb1 100644 --- a/cmd/moveto/moveto.go +++ b/cmd/moveto/moveto.go @@ -3,10 +3,10 @@ package moveto import ( "context" - "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs/operations" + "github.com/rclone/rclone/fs/operations/operationsflags" "github.com/rclone/rclone/fs/sync" "github.com/spf13/cobra" ) diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index fb26fdca8..ecde7d388 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -3,6 +3,7 @@ package sync import ( "context" + "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/operations" diff --git a/fs/operations/logger.go b/fs/operations/logger.go index f4b8fb820..0d482206f 100644 --- a/fs/operations/logger.go +++ b/fs/operations/logger.go @@ -107,6 +107,7 @@ type LoggerOpt struct { Absolute bool } +// NewDefaultLoggerFn creates a logger function that writes the sigil and path to configured files that match the sigil func NewDefaultLoggerFn(opt *LoggerOpt) LoggerFn { var lock mutex.Mutex diff --git a/fs/operations/operationsflags/operationsflags.go b/fs/operations/operationsflags/operationsflags.go index 0242dab16..dac217657 100644 --- a/fs/operations/operationsflags/operationsflags.go +++ b/fs/operations/operationsflags/operationsflags.go @@ -4,14 +4,15 @@ package operationsflags import ( "context" + "io" + "os" + "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/hash" "github.com/rclone/rclone/fs/operations" "github.com/spf13/cobra" "github.com/spf13/pflag" - "io" - "os" ) // AddLoggerFlagsOptions contains options for the Logger Flags @@ -25,6 +26,7 @@ type AddLoggerFlagsOptions struct { DestAfter string // files that exist on the destination post-sync } +// AnySet checks if any of the logger flags have a non-blank value func (o AddLoggerFlagsOptions) AnySet() bool { return anyNotBlank(o.Combined, o.MissingOnSrc, o.MissingOnDst, o.Match, o.Differ, o.ErrFile, o.DestAfter) } @@ -62,6 +64,7 @@ func AddLoggerFlags(cmdFlags *pflag.FlagSet, opt *operations.LoggerOpt, flagsOpt // flags.BoolVarP(cmdFlags, &recurse, "recursive", "R", false, "Recurse into the listing", "") } +// ConfigureLoggers verifies and sets up writers for log files requested via CLI flags func ConfigureLoggers(ctx context.Context, fdst fs.Fs, command *cobra.Command, opt *operations.LoggerOpt, flagsOpt AddLoggerFlagsOptions) (func(), error) { closers := []io.Closer{}