Skip to content

fs: fix --bwlimit timetables written out of order using the wrong limit - #9987

Merged
ncw merged 2 commits into
rclone:masterfrom
r0h1tb:fix/bwlimit-wraparound
Sep 30, 2026
Merged

ncw merged 2 commits into
rclone:masterfrom
r0h1tb:fix/bwlimit-wraparound

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

What does this change do?

Before the first time slot of the week, LimitAt falls back to the last entry of the timetable as the limit carried over from the previous week. That's only right when the entries are in week order, so the same timetable gives different limits depending on how it's written:

--bwlimit "Mon-00:00,1M Sat-00:00,off"   Sunday 10:00 -> off
--bwlimit "Sat-00:00,off Mon-00:00,1M"   Sunday 10:00 -> 1Mi

Writing the weekend first is a natural way to say "unlimited at weekends", and it throttles Sunday morning. Weekday-less entries hit it too: "12:00,1M Mon-00:00,512" gives 512Ki at Sunday 10:00, where the most recent slot is Saturday 12:00.

The fallback is now the latest slot in the week, which is the same entry as before whenever the timetable is in order, so only out-of-order timetables change.

The second commit fixes the expanded example in the --bwlimit docs, which was missing a space (512Mon-12:00) and didn't parse.

Tests: new case in TestBwTimetableLimitAt with the weekend-first timetable, which returns the Monday slot on master. make quicktest matches master (cmd/gitannex fails on both, no git-annex here) and golangci-lint run ./fs/ reports 0 issues.

Linked issue

None.

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • This Pull Request is ready for review.

Until the first time slot of the week, the timetable used its last entry
as the limit carried over from the week before. That is only the latest
slot of the week when the entries are in order, so a timetable written
weekend first, like "Sat-00:00,off Mon-00:00,1M", limited Sunday to 1M
instead of leaving it unlimited.

Carry over the latest time slot of the week instead.
It was missing a space between two entries, so it didn't parse.
@r0h1tb
r0h1tb requested a review from ncw as a code owner September 26, 2026 23:31

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for both fixes :-)

@ncw
ncw merged commit e497464 into rclone:master Sep 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants