From 7701d1d33d402c0a22daa8949bf3d0c61f689057 Mon Sep 17 00:00:00 2001
From: Vitor Gomes <mail@vitorgomes.com>
Date: Mon, 7 Aug 2023 22:51:06 +0200
Subject: [PATCH] config: add "multi-thread-chunk-size" flag #7056

---
 fs/config.go                         | 6 ++++--
 fs/config/configflags/configflags.go | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/config.go b/fs/config.go
index 060567447..c0bd306f8 100644
--- a/fs/config.go
+++ b/fs/config.go
@@ -145,8 +145,9 @@ type ConfigInfo struct {
 	Metadata                   bool
 	ServerSideAcrossConfigs    bool
 	TerminalColorMode          TerminalColorMode
-	DefaultTime                Time // time that directories with no time should display
-	Inplace                    bool // Download directly to destination file instead of atomic download to temp/rename
+	DefaultTime                Time       // time that directories with no time should display
+	Inplace                    bool       // Download directly to destination file instead of atomic download to temp/rename
+	MultiThreadChunkSize       SizeSuffix // Chunk size for multi-thread downloads / uploads, if not set by filesystem
 }
 
 // NewConfig creates a new config with everything set to the default
@@ -184,6 +185,7 @@ func NewConfig() *ConfigInfo {
 	//	c.StatsOneLineDateFormat = "2006/01/02 15:04:05 - "
 	c.MultiThreadCutoff = SizeSuffix(250 * 1024 * 1024)
 	c.MultiThreadStreams = 4
+	c.MultiThreadChunkSize = SizeSuffix(50 * 1024 * 1024)
 
 	c.TrackRenamesStrategy = "hash"
 	c.FsCacheExpireDuration = 300 * time.Second
diff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.go
index 3839691d0..36ff2cb6f 100644
--- a/fs/config/configflags/configflags.go
+++ b/fs/config/configflags/configflags.go
@@ -127,6 +127,7 @@ func AddFlags(ci *fs.ConfigInfo, flagSet *pflag.FlagSet) {
 	flags.FVarP(flagSet, &ci.MultiThreadCutoff, "multi-thread-cutoff", "", "Use multi-thread downloads for files above this size", "Copy")
 	flags.IntVarP(flagSet, &ci.MultiThreadStreams, "multi-thread-streams", "", ci.MultiThreadStreams, "Max number of streams to use for multi-thread downloads", "Copy")
 	flags.FVarP(flagSet, &ci.MultiThreadWriteBufferSize, "multi-thread-write-buffer-size", "", "In memory buffer size for writing when in multi-thread mode", "Copy")
+	flags.FVarP(flagSet, &ci.MultiThreadChunkSize, "multi-thread-chunk-size", "", "Chunk size for multi-thread downloads / uploads, if not set by filesystem", "Copy")
 	flags.BoolVarP(flagSet, &ci.UseJSONLog, "use-json-log", "", ci.UseJSONLog, "Use json log format", "Logging")
 	flags.StringVarP(flagSet, &ci.OrderBy, "order-by", "", ci.OrderBy, "Instructions on how to order the transfers, e.g. 'size,descending'", "Copy")
 	flags.StringArrayVarP(flagSet, &uploadHeaders, "header-upload", "", nil, "Set HTTP header for upload transactions", "Networking")