Skip to content

fix(downloads): persist failed downloads and offer retry - #6

Merged
ghostcoder42 merged 1 commit into
mainfrom
fix/download-failure-retry
Sep 3, 2026
Merged

ghostcoder42 merged 1 commit into
mainfrom
fix/download-failure-retry

Conversation

@ghostcoder42

Copy link
Copy Markdown
Owner

A failed download used to end with a single Cancel action and vanished on the next app start: the active-downloads store was memory-only, so there was nothing left to retry from — the download (and its partial file) was simply gone.

Failed tasks are now persisted to MMKV (with the source URL, composite video id and quality captured when the transfer starts) and restored on app start, so they reappear in the Downloads tab. Error rows get a Retry button next to Cancel: retry restarts the task in place, drops any partial file, and prefers the stored direct URL — falling back to re-scraping the video page via the stored slug when the failure happened before a source was captured.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

💯 Test Coverage

Lines Statements Branches Functions
Coverage: 52%
51.76% (805/1555) 43.31% (395/912) 42.62% (214/502)

😎 Tests Results

Tests Skipped Failures Errors Time
257 0 💤 0 ❌ 0 🔥 22.687s ⏱️
👀 Tests Details • (52%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files51.7643.3142.6252.21 
src/app/(app)0000 
   _layout.tsx000021–95
   library.tsx000021–402
src/lib/download59.3354.5454.1660.41 
   download-video.ts73.5656.8655.557538–42, 78–81, 96, 100–105, 157–158, 205–213
src/lib/hooks46.426.196045.52 
   use-download-settings.tsx5033.3333.33509–16
   use-video-actions.ts37.2510.7172.7231.741–42, 57–91, 101–120
   use-video-download.ts7545.8310078.7846, 85–91
src/lib/stores97.189.3698.6399.29 
   active-downloads-store.ts93.7578.2610010082, 102, 141–162

@ghostcoder42
ghostcoder42 force-pushed the fix/download-failure-retry branch from 7840e13 to 2a9f037 Compare September 3, 2026 05:54
Downloads lived entirely in memory: a failure ended with a single
Cancel action, and killing (or crashing) the app mid-transfer lost
the task completely — nothing to retry from, and the partial file was
swept away as an orphan on the next launch.

Tasks are now persisted to MMKV from the moment they start, with the
source URL, composite video id and quality captured when the transfer
begins, and restored on app start in the Downloads tab:

- failed downloads come back with their error message;
- downloads interrupted by an app restart come back as 'Interrupted'
  with their stale progress cleared;

both with a Retry button next to Cancel. Retry restarts the task in
place and drops any partial file — interrupted transfers resume as
fresh downloads, not byte-level resumes. It prefers the stored direct
URL (which can outlive the video page) and, when the failure happened
before a source was captured, re-scrapes the video page via the
stored slug.
@ghostcoder42
ghostcoder42 force-pushed the fix/download-failure-retry branch from 2a9f037 to 3e14556 Compare September 3, 2026 06:03
@ghostcoder42
ghostcoder42 merged commit d5bf950 into main Sep 3, 2026
1 check passed
@ghostcoder42
ghostcoder42 deleted the fix/download-failure-retry branch September 3, 2026 06:05
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.

1 participant