Skip to content

Recover missing album tracks during incremental scans - #127

Merged
lostf1sh merged 1 commit into
mainfrom
fix/recover-missing-album-tracks
Sep 17, 2026
Merged

lostf1sh merged 1 commit into
mainfrom
fix/recover-missing-album-tracks

Conversation

@lostf1sh

Copy link
Copy Markdown
Collaborator

Incremental sync can leave an imported album incomplete when MediaStore exposes additional tracks with timestamps older than the last sync. The folder picker can count all 16 files while the library still shows only the 3 tracks imported earlier.

Compare the eligible MediaStore IDs with the local database during the existing deletion scan. If any IDs are missing locally, query without a timestamp cutoff and retain the existing unchanged-song checks and metadata-edit preservation. Normal incremental scans resume once the IDs match.

Related to #126. The reporter's original files were unavailable; the regression test covers a reproducible cause of the reported mismatch.

Validation:

  • Kotlin compilation and the full JVM test suite passed, including a rerun after updating to the latest main.
  • All 3 SyncWorkerTest instrumented tests passed on Android 16. The new regression failed with 3/16 tracks before the fix and recovered all 16 afterward, preserved an edited title, and verified that the next scan uses its timestamp filter again.
  • lintDebug ran and reported 94 existing errors in unchanged playback and translation files; none are in the changed code.

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no actionable correctness, security, or repository-rule violations identified.

Summary

This PR makes incremental local-library synchronization recover eligible MediaStore tracks whose timestamps predate the current sync watermark.

  • Compares eligible MediaStore IDs with locally stored MediaStore IDs during reconciliation.
  • Removes the timestamp cutoff when eligible tracks are missing locally while retaining unchanged-song filtering and user-edit preservation.
  • Adds an instrumented regression test covering incomplete-album recovery, edited-title preservation, and restoration of normal incremental filtering.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Incremental sync starts] --> B[Read local MediaStore IDs]
    B --> C[Read current eligible MediaStore IDs]
    C --> D{Eligible ID missing locally?}
    D -- No --> E[Query with incremental timestamp cutoff]
    D -- Yes --> F[Query without timestamp cutoff]
    E --> G[Apply unchanged-song checks]
    F --> G
    G --> H[Preserve user-edited metadata]
    H --> I[Upsert changed and missing tracks]
    I --> J[Next scan compares IDs again]
Loading

Reviews (1) · Last reviewed commit: "Recover missing album tracks during incr..."

@lostf1sh
lostf1sh merged commit 28437d9 into main Sep 17, 2026
3 checks passed
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