Repository navigation
fs: add --max-errors flag - fixes #4670 - #10271
Conversation
Add --max-errors N to stop transferring once N errors have been counted. Errors from previous --retries attempts are included. With --cutoff-mode hard (the default) rclone stops with a fatal error. With soft (and cautious) no new transfers are started and running transfers are allowed to finish. No further retries are attempted once the limit is reached.
ncw
left a comment
There was a problem hiding this comment.
Thank you for doing this - it looks very nice :-)
I think there is one thing missing.
In cmd/cmd.go can you adjust resolveExitCode for consistency with --max-transfer (8) and --max-duration (10) so that --max-errors has a dedicated exit code? And adjust the docs accordingly.
Thanks
|
Thanks! Done in 8f8e26d.
I checked the built binary by copying a directory with unreadable files: I pushed this as a second commit so the change is easy to see. I can squash it if you prefer. |
What does this change do?
Adds a global
--max-errors Nflag that stops rclone transferring once N errors have been counted, as suggested in #4670: it sits next to--max-transferand--max-durationand honours--cutoff-mode.HARD(default): the next transfer that would start returns a fatal error, so sync cancels and no retries are attempted.SOFT/CAUTIOUS: no new transfers are started, transfers already in progress finish (same path as--max-transferwithSOFT).--retriesattempts count too.StatsInfogets atotalErrorscounter thatResetErrors()(called between retries) leaves alone, andcmd.Runstops retrying once the limit is reached.The check is in
(*copy).checkLimits, so it gates the start of each transfer. It does not interrupt a transfer mid-read, and deletes/checks in sync are not gated. The docs say "no new transfers will be started".I didn't add a dedicated exit code:
HARDexits 7 (fatal error) andSOFTexits 9 (no-retry error). Happy to add one alongside 8 (--max-transfer) and 10 (--max-duration) if you'd like.Tests:
TestStatsTotalErrors(count survivesResetErrors),TestCopyFileMaxErrors(fatal vs graceful error per cutoff mode) andTestMaxErrors/{Hard,Soft,Cautious}in fs/sync. I also ran it end to end with unreadable source files and--retries 3.Linked issue
Fixes #4670
Checklist
test_allpasses for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.