"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
operations: implement --partial-suffix to control extension of temporary file names
Volodymyr6255d9dfaa93
diff --git a/docs/content/docs.md b/docs/content/docs.mdindex de6459a17..a3ddf79f9 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -1278,8 +1278,9 @@ flag set) such as:- sftpWithout `--inplace` (the default) rclone will first upload to a-temporary file with an extension like this where `XXXXXX` represents a-random string.+temporary file with an extension like this, where `XXXXXX` represents a+random string and `.partial` is [--partial-suffix](#partial-suffix) value+(`.partial` by default).original-file-name.XXXXXX.partial@@ -1726,6 +1727,15 @@ If you want perfect ordering then you will need to specify[--check-first](#check-first) which will find all the files which needtransferring first before transferring any.+### --partial-suffix {#partial-suffix}++When [--inplace](#inplace) is not used, it causes rclone to use+the `--partial-suffix` as suffix for temporary files.++Suffix length limit is 16 characters.++The default is `.partial`.+### --password-command SpaceSepList ###This flag supplies a program which should supply the config passworddiff --git a/fs/config.go b/fs/config.goindex 9c8449913..bef0f1693 100644--- a/fs/config.go+++ b/fs/config.go@@ -148,6 +148,7 @@ type ConfigInfo struct {TerminalColorMode TerminalColorModeDefaultTime Time // time that directories with no time should displayInplace bool // Download directly to destination file instead of atomic download to temp/rename+ PartialSuffix string}// NewConfig creates a new config with everything set to the default@@ -192,6 +193,7 @@ func NewConfig() *ConfigInfo {c.FsCacheExpireInterval = 60 * time.Secondc.KvLockTime = 1 * time.Secondc.DefaultTime = Time(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC))+ c.PartialSuffix = ".partial"// 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 37ed76e2c..4c9709c0e 100644--- a/fs/config/configflags/configflags.go+++ b/fs/config/configflags/configflags.go@@ -38,6 +38,7 @@ var (downloadHeaders []stringheaders []stringmetadataSet []string+ partialSuffix string)// AddFlags adds the non filing system specific flags to the command@@ -148,6 +149,7 @@ func AddFlags(ci *fs.ConfigInfo, flagSet *pflag.FlagSet) {flags.FVarP(flagSet, &ci.TerminalColorMode, "color", "", "When to show colors (and other ANSI codes) AUTO|NEVER|ALWAYS", "Config")flags.FVarP(flagSet, &ci.DefaultTime, "default-time", "", "Time to show if modtime is unknown for files and directories", "Config,Listing")flags.BoolVarP(flagSet, &ci.Inplace, "inplace", "", ci.Inplace, "Download directly to destination file instead of atomic download to temp/rename", "Copy")+ flags.StringVarP(flagSet, &partialSuffix, "partial-suffix", "", ci.PartialSuffix, "Add partial-suffix to temporary file name when --inplace is not used", "Copy")}// ParseHeaders converts the strings passed in via the header flags into HTTPOptions@@ -322,6 +324,11 @@ func SetFlags(ci *fs.ConfigInfo) {multiThreadStreamsFlag := pflag.Lookup("multi-thread-streams")ci.MultiThreadSet = multiThreadStreamsFlag != nil && multiThreadStreamsFlag.Changed+ if len(partialSuffix) > 16 {+ log.Fatalf("--partial-suffix: Expecting suffix length not greater than %d but got %d", 16, len(partialSuffix))+ }+ ci.PartialSuffix = partialSuffix+// Make sure some values are > 0nonZero := func(pi *int) {if *pi <= 0 {diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex 441c30971..3c1ced8db 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -359,9 +359,13 @@ func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.ObjremotePartial = remote)if !ci.Inplace && f.Features().Move != nil && f.Features().PartialUploads && !strings.HasSuffix(remote, ".rclonelink") {+ if len(ci.PartialSuffix) > 16 {+ return nil, fmt.Errorf("expecting length of --partial-suffix to be not greater than %d but got %d", 16, len(ci.PartialSuffix))+ }+// Avoid making the leaf name longer if it's already lengthy to avoid// trouble with file name length limits.- suffix := "." + random.String(8) + ".partial"+ suffix := "." + random.String(8) + ci.PartialSuffixbase := path.Base(remotePartial)if len(base) > 100 {remotePartial = remotePartial[:len(remotePartial)-len(suffix)] + suffix