Home

dev / openkara

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

feat(remote): resumable provider transfers and shared network retry policy (#151)

2 months ago

32bb84d
Authored
Davy7/20/2026, 2:04:06 PM
Add a unified network retry policy (net_policy.rs) with exponential backoff,
full jitter, Retry-After header honoring, cancellation, and persisted attempt
progress. The policy classifies temporary failures (connection/timeout, HTTP
408/425/429/5xx) as retryable and permanent failures (400/403/404/409/412) as
immediate-abort, sharing classification helpers with the streaming range
fetcher.

Implement resumable uploads for each provider:
- Dropbox: upload_session start/append_v2/finish with persisted session_id
  and offset.
- Google Drive: resumable upload via uploadType=resumable with session URL,
  chunked PUT, and 308 status offset query.
- WebDAV: staged PUT to .openkara/staging/<op-id>/ + server-side MOVE to
  the final path (resumable_upload stays false; server_side_move = true).

Implement resumable downloads in atomic_download.rs: resume from a verified
offset via Range requests, persist progress to remote_transfer_parts, and
invalidate the partial on provider_revision mismatch. The executor's candidate
DB upload uses the resumable path for files >= 8 MiB.

Fix defect #10 in ProviderFetcher credential refresh: replace the
refresh_attempted AtomicBool (which allowed only one refresh per fetcher
lifetime and never reset) with a credential_generation AtomicU64 and a
single-flight refresh guard. Concurrent expired requests trigger one refresh;
waiting requests observe the new generation and retry. 401 triggers refresh;
403 (permission denial) is permanent and not retried. A successful request
advances the generation so a future expiry can refresh again.

Replace the PR#5 placeholder recovery test with real tests for incomplete
transfer-part detection and revision-mismatch invalidation.

Refs #151

Parent71d9479

14 files changed
  • src-tauri/Cargo.lock+1−0
  • src-tauri/Cargo.toml+1−0
  • src-tauri/src/audio/remote_source.rs+278−20
  • src-tauri/src/remote/atomic_download.rs+614−0
  • src-tauri/src/remote/control_db.rs+15−0
  • src-tauri/src/remote/dropbox.rs+208−1
  • src-tauri/src/remote/errors.rs+9−0
  • src-tauri/src/remote/executor.rs+23
−3
  • src-tauri/src/remote/google_drive.rs+280−1
  • src-tauri/src/remote/mod.rs+1−0
  • src-tauri/src/remote/net_policy.rs+610−0
  • src-tauri/src/remote/provider.rs+46−0
  • src-tauri/src/remote/recovery.rs+83−4
  • src-tauri/src/remote/webdav.rs+114−2