"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fs: Add --default-time flag to control unknown modtime of files/dirs
Nick Craig-Wood8e2dc069d2e4
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex 941c9c842..22e8c8c93 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -992,6 +992,18 @@ Mode to run dedupe command in. One of `interactive`, `skip`, `first`,`newest`, `oldest`, `rename`. The default is `interactive`.See the dedupe command for more information as to what these options mean.+### --default-time TIME ###++If a file or directory does have a modification time rclone can read+then rclone will display this fixed time instead.++The default is `2000-01-01 00:00:00 UTC`. This can be configured in+any of the ways shown in [the time or duration options](#time-option).++For example `--default-time 2020-06-01` to set the default time to the+1st of June 2020 or `--default-time 0s` to set the default time to the+time rclone started up.+### --disable FEATURE,FEATURE,... ###This disables a comma separated list of optional features. For examplediff --git a/fs/config.go b/fs/config.goindex 4049b6ea4..d243d794a 100644--- a/fs/config.go+++ b/fs/config.go@@ -144,6 +144,7 @@ type ConfigInfo struct {Metadata boolServerSideAcrossConfigs boolTerminalColorMode TerminalColorMode+ DefaultTime Time // time that directories with no time should display}// NewConfig creates a new config with everything set to the default@@ -185,6 +186,7 @@ func NewConfig() *ConfigInfo {c.FsCacheExpireDuration = 300 * time.Secondc.FsCacheExpireInterval = 60 * time.Secondc.KvLockTime = 1 * time.Second+ c.DefaultTime = Time(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC))// Perform a simple check for debug flags to enable debug logging during the flag initializationfor argIndex, arg := range os.Args {diff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.goindex 96d728fcc..63f107fd0 100644--- a/fs/config/configflags/configflags.go+++ b/fs/config/configflags/configflags.go@@ -144,6 +144,7 @@ func AddFlags(ci *fs.ConfigInfo, flagSet *pflag.FlagSet) {flags.BoolVarP(flagSet, &ci.Metadata, "metadata", "M", ci.Metadata, "If set, preserve metadata when copying objects")flags.BoolVarP(flagSet, &ci.ServerSideAcrossConfigs, "server-side-across-configs", "", ci.ServerSideAcrossConfigs, "Allow server-side operations (e.g. copy) to work across different configs")flags.FVarP(flagSet, &ci.TerminalColorMode, "color", "", "When to show colors (and other ANSI codes) AUTO|NEVER|ALWAYS")+ flags.FVarP(flagSet, &ci.DefaultTime, "default-time", "", "Time to show if modtime is unknown for files and directories")}// ParseHeaders converts the strings passed in via the header flags into HTTPOptionsdiff --git a/fs/dir.go b/fs/dir.goindex 63c51a310..c55bcea23 100644--- a/fs/dir.go+++ b/fs/dir.go@@ -16,6 +16,8 @@ type Dir struct {}// NewDir creates an unspecialized Directory object+//+// If the modTime is unknown pass in time.Time{}func NewDir(remote string, modTime time.Time) *Dir {return &Dir{remote: remote,@@ -75,12 +77,14 @@ func (d *Dir) SetParentID(parent string) *Dir {}// ModTime returns the modification date of the file-// It should return a best guess if one isn't available+//+// If one isn't available it returns the configured --default-dir-timefunc (d *Dir) ModTime(ctx context.Context) time.Time {if !d.modTime.IsZero() {return d.modTime}- return time.Now()+ ci := GetConfig(ctx)+ return time.Time(ci.DefaultTime)}// Size returns the size of the file