Home

dev / openkara

publicthedavidweng/OpenKara· sync paused
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix(remote): bound streaming range fetches and stream downloads to disk (#204, #205) (#216)

2 months ago

f1afa6e
Authored
Davy7/25/2026, 6:20:26 PM
Two remote-library HTTP robustness fixes in src-tauri.

#204 — streaming playback range fetcher had no timeouts:
ProviderFetcher and ReqwestFetcher were built with
`reqwest::blocking::Client::new()` (no connect/read timeout), so a
half-open/stalled connection parked the fetch thread forever and defeated
the retry/reconnect safety net. Build both clients with an explicit
connect timeout and a per-request timeout, and consume the range body with
a streaming `read()` loop so reqwest's blocking `Read` applies that timeout
as a per-read idle timeout: a stall now trips a bounded `FetchError::Io`
(feeding fetch_range_with_retry → ConsecutiveFailures → reconnect and
letting the fetch thread exit), while a slow-but-steady weak link keeps
making progress.

#205 — downloads buffered the whole file/chunk with response.bytes():
Both `download_file` and 8 MiB-chunk `download_range` across WebDAV,
Dropbox, and Google Drive read the entire body under one total-body
deadline, so 2G-class links timed out with zero durable progress and every
interruption discarded up to 8 MiB. Add `net_policy::stream_response_body`
(a per-read idle-timeout streaming loop with a wall-clock budget) and route
all six paths through it, writing bytes to the destination/part file as
they arrive. The resumable driver now persists the actual on-disk length on
a mid-chunk failure and clamps the resume point to it, so interruptions
resume sub-chunk instead of re-downloading the whole chunk; the final
size/digest validation is unchanged.

Tests: streaming trickle-succeeds / stall-times-out-with-partial-write and
oversize-cap (net_policy); ProviderFetcher stall returns a bounded error and
a timed-out fetch drives ConsecutiveFailures + clean thread join
(remote_source); sub-chunk resume completes with a verified digest
(atomic_download); full-body streaming through the WebDAV provider path.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Parentc5dfec9

6 files changed
  • src-tauri/src/audio/remote_source.rs+253−8
  • src-tauri/src/remote/atomic_download.rs+181−6
  • src-tauri/src/remote/dropbox.rs+47−38
  • src-tauri/src/remote/google_drive.rs+48−36
  • src-tauri/src/remote/net_policy.rs+251−1
  • src-tauri/src/remote/webdav.rs+77−57