Skip to content

Link existing downloads after library sync#14

Merged
Promises merged 3 commits into
Promises:mainfrom
kvmgithub:main
May 25, 2026
Merged

Link existing downloads after library sync#14
Promises merged 3 commits into
Promises:mainfrom
kvmgithub:main

Conversation

@kvmgithub
Copy link
Copy Markdown
Contributor

Summary

This change links existing Android audiobook files after library sync. When the Library sync finishes, LibriSync scans the configured Download Directory, matches existing audio files to synced audiobooks, and records the matching file path as a completed download.

It also tightens the sync entry point: users must choose a Download Directory before starting Library sync, and the Library view can now sort by downloaded state.

What changed

  • Added Android existing-download scanning for the saved Download Directory after manual and scheduled Library syncs.
  • Matched existing files to synced audiobooks by ASIN, title, author, and series so files can still be linked when the filename pattern has changed.
  • Reused completed download tasks for linked files so the Library sees them as downloaded without duplicating task history.
  • Persisted and reused the selected Download Directory through the Android bridge so background sync can scan the same directory.
  • Added a pre-sync Download Directory prompt when no directory has been configured yet.
  • Added a Downloaded Library sort mode.
  • Made Downloaded sort group downloaded and not-downloaded books while preserving the previous sort inside each group.
  • Exposed completed download file paths through the Rust book query layer so linked files surface in the UI.

User impact

Users who already have audiobooks in the selected Download Directory can sync their Library and have those existing files linked automatically instead of downloading them again or manually link the downloaded file.

The Download Directory requirement makes the sync flow explicit before any existing-download scan runs. The new Downloaded sort makes it easier to review what is already linked locally and what is still missing.

Implementation notes

The Android scanner handles both SAF/content URI directories and file paths. It walks audio files recursively, builds matching candidates from audiobook metadata, and skips ambiguous matches.

The Rust storage query now joins completed download tasks into Library results. The downloaded sort is implemented as a grouping sort: downloaded status determines the outer group order, while the prior Library sort is used inside each group.

Validation

Automated and build validation run for this branch:

  • npm run typecheck
  • cargo check
  • cargo test --lib test_list_books_with_filters_sorts_by_downloaded_status
  • cargo test --lib test_set_book_file_path_updates_existing_completed_task
  • ./gradlew :app:compileDebugKotlin
  • git diff --check

Local Android validation also performed:

  • npm run build:rust:android
  • npx expo run:android
  • ./gradlew :app:assembleRelease
  • Installed and tested the app; no abnormal behavior observed.
  • Existing-download matching tested with the default file naming pattern.
  • Other file naming patterns have not yet been validated for the existing-download check.

@kvmgithub kvmgithub marked this pull request as ready for review May 22, 2026 20:01
@Promises
Copy link
Copy Markdown
Owner

Thank you, has been bugging me while testing

@Promises Promises merged commit 9455ee9 into Promises:main May 25, 2026
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.

2 participants