vfs/cache: fix exponentially growing error messages in download retries by mango766 · Pull Request #9258 · rclone/rclone

@claude

When the VFS cache runs out of space and download retries occur, error
messages grow exponentially because each retry wraps the previous
error with the same "vfs reader: failed to write to cache file:" prefix.
This happens because kickWaiters() propagates the lastErr (from a
previous download attempt) back through Write(), and download() wraps
it again unconditionally.

After ~243 retries the error message contains the prefix repeated 243
times, causing massive log files (reported in issue rclone#4998).

Fix by checking whether the error already contains the wrapping prefix
before adding it again in download(). Extract the prefix string into a
named constant to keep the check DRY.

Fixes rclone#4998

Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>