"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: Allow semicolons as well as spaces in --bwlimit timetable parsing - fixes #7595
Kyle Reynoldsd4b29fef9211
diff --git a/docs/content/commands/rclone.md b/docs/content/commands/rclone.mdindex 4cf7350d2..c73ff6f5e 100644--- a/docs/content/commands/rclone.md+++ b/docs/content/commands/rclone.md@@ -123,7 +123,7 @@ rclone [flags]--box-token-url string Token server url--box-upload-cutoff SizeSuffix Cutoff for switching to multipart upload (>= 50 MiB) (default 50Mi)--buffer-size SizeSuffix In memory buffer size when reading files for each --transfer (default 16Mi)- --bwlimit BwTimetable Bandwidth limit in KiB/s, or use suffix B|K|M|G|T|P or a full timetable+ --bwlimit BwTimetable Bandwidth limit in KiB/s, or use suffix B|K|M|G|T|P or a full timetable.--bwlimit-file BwTimetable Bandwidth limit per file in KiB/s, or use suffix B|K|M|G|T|P or a full timetable--ca-cert stringArray CA certificate used to verify servers--cache-chunk-clean-interval Duration How often should the cache perform cleanups of the chunk storage (default 1m0s)diff --git a/docs/content/docs.md b/docs/content/docs.mdindex 49180b0ed..c4ef41783 100644--- a/docs/content/docs.md+++ b/docs/content/docs.md@@ -724,12 +724,20 @@ for upload:download, e.g.`10M:1M`.characters. It is optional.- `HH:MM` is an hour from 00:00 to 23:59.+Entries can be separated by spaces or semicolons.++**Note:** Semicolons can be used as separators instead of spaces to avoid parsing issues in environments like Docker.+An example of a typical timetable to avoid link saturation during daytimeworking hours could be:+Using spaces as separators:`--bwlimit "08:00,512k 12:00,10M 13:00,512k 18:00,30M 23:00,off"`-In this example, the transfer bandwidth will be set to 512 KiB/s+Using semicolons as separators:+`--bwlimit "08:00,512k;12:00,10M;13:00,512k;18:00,30M;23:00,off"`++In these examples, the transfer bandwidth will be set to 512 KiB/sat 8am every day. At noon, it will rise to 10 MiB/s, and drop backto 512 KiB/sec at 1pm. At 6pm, the bandwidth limit will be set to30 MiB/s, and at 11pm it will be completely disabled (full speed).@@ -737,8 +745,12 @@ Anything between 11pm and 8am will remain unlimited.An example of timetable with `WEEKDAY` could be:+Using spaces as separators:`--bwlimit "Mon-00:00,512 Fri-23:59,10M Sat-10:00,1M Sun-20:00,off"`+Using semicolons as separators:+`--bwlimit "Mon-00:00,512;Fri-23:59,10M;Sat-10:00,1M;Sun-20:00,off"`+It means that, the transfer bandwidth will be set to 512 KiB/s onMonday. It will rise to 10 MiB/s before the end of Friday. At 10:00on Saturday it will be set to 1 MiB/s. From 20:00 on Sunday it willdiff --git a/fs/bwtimetable.go b/fs/bwtimetable.goindex 3361fd61f..eb01a8d76 100644--- a/fs/bwtimetable.go+++ b/fs/bwtimetable.go@@ -150,7 +150,10 @@ func (x *BwTimetable) Set(s string) error {return nil}- for _, tok := range strings.Split(s, " ") {+ // Split the timetable string by both spaces and semicolons+ for _, tok := range strings.FieldsFunc(s, func(r rune) bool {+ return r == ' ' || r == ';'+ }) {tv := strings.Split(tok, ",")// Format must be dayOfWeek-HH:MM,BWdiff --git a/fs/bwtimetable_test.go b/fs/bwtimetable_test.goindex 67f4057a3..b1d45f567 100644--- a/fs/bwtimetable_test.go+++ b/fs/bwtimetable_test.go@@ -256,6 +256,53 @@ func TestBwTimetableSet(t *testing.T) {false,"Mon-00:00,512Ki Sun-12:00,1Mi Mon-12:00,1Mi Tue-12:00,1Mi Wed-12:00,1Mi Thu-12:00,1Mi Fri-12:00,1Mi Sat-12:00,1Mi Sun-20:00,off",},+ {+ "11:00,333;13:40,666;23:50,10M;23:59,off",+ BwTimetable{+ BwTimeSlot{DayOfTheWeek: 0, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 2, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 3, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 4, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 5, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 6, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 0, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 1, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 3, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 4, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 5, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 6, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ BwTimeSlot{DayOfTheWeek: 0, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 1, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 2, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 3, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 4, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 5, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 6, HHMM: 2350, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 0, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 1, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 2, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 3, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 4, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 5, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 6, HHMM: 2359, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ },+ false,+ "Sun-11:00,333Ki Mon-11:00,333Ki Tue-11:00,333Ki Wed-11:00,333Ki Thu-11:00,333Ki Fri-11:00,333Ki Sat-11:00,333Ki Sun-13:40,666Ki Mon-13:40,666Ki Tue-13:40,666Ki Wed-13:40,666Ki Thu-13:40,666Ki Fri-13:40,666Ki Sat-13:40,666Ki Sun-23:50,10Mi Mon-23:50,10Mi Tue-23:50,10Mi Wed-23:50,10Mi Thu-23:50,10Mi Fri-23:50,10Mi Sat-23:50,10Mi Sun-23:59,off Mon-23:59,off Tue-23:59,off Wed-23:59,off Thu-23:59,off Fri-23:59,off Sat-23:59,off",+ },+ {+ "Mon-11:00,333;Tue-13:40,666:333;Fri-00:00,10M;Sat-10:00,off;Sun-23:00,666",+ BwTimetable{+ BwTimeSlot{DayOfTheWeek: 1, HHMM: 1100, Bandwidth: BwPair{Tx: 333 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 2, HHMM: 1340, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 333 * 1024}},+ BwTimeSlot{DayOfTheWeek: 5, HHMM: 0000, Bandwidth: BwPair{Tx: 10 * 1024 * 1024, Rx: 10 * 1024 * 1024}},+ BwTimeSlot{DayOfTheWeek: 6, HHMM: 1000, Bandwidth: BwPair{Tx: -1, Rx: -1}},+ BwTimeSlot{DayOfTheWeek: 0, HHMM: 2300, Bandwidth: BwPair{Tx: 666 * 1024, Rx: 666 * 1024}},+ },+ false,+ "Mon-11:00,333Ki Tue-13:40,666Ki:333Ki Fri-00:00,10Mi Sat-10:00,off Sun-23:00,666Ki",+ },} {tt := BwTimetable{}err := tt.Set(test.in)