Skip to content

fix(scanner): leave a music video out of the walk - #450

Merged
InstaZDLL merged 2 commits into
mainfrom
fix/scanner-music-video-not-a-track
Nov 14, 2026
Merged

InstaZDLL merged 2 commits into
mainfrom
fix/scanner-music-video-not-a-track

Conversation

@InstaZDLL

@InstaZDLL InstaZDLL commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

PR 1 of RFC-029, decision 4. It fixes a defect present today.

The defect

mp4 is an audio extension, and rightly so: an .mp4 often holds nothing but AAC. A music video placed beside its song, as Album/Song.mp4 next to Album/Song.flac or in Album/Clips/, was therefore indexed as a second track whose audio was the clip's soundtrack. The desktop fixed the same defect in its own walk, in v2.1.0.

The change

  • discover_audio drops the clips with the core's own scanner::clips::drop_clips. It runs it on the catalogue names, which are the folders as the library shows them, and confirms each candidate with file_has_video_track. The rule is the desktop's, not a copy of it:
    • an .mp4 goes only when a file of its name sits beside it, or above its Clips folder, and it holds a moving picture;
    • an audio .mp4 stays a track whatever its neighbours;
    • a video with no song of its name stays a track.
  • Only audio files are given to the rule. A .webm or .mkv is not an audio extension and never reaches the walk, so it cannot turn its namesake .mp4 into a clip. This is the split between the two sets that the RFC review asked for.
  • normalised_scope treats a Clips folder as the folder above it (RFC-029 decision 3, moved forward into this PR). The watcher scopes a scan to the folder where a change happened. A clip dropped into Album/Clips/ is told apart from a track only by the song in Album/, so a scan of the Clips folder alone would have indexed it. A Clips folder at the root means the whole library.

What it changes for an existing catalogue

A video already indexed as a track is no longer in the walk. The next scan handles it like a deleted file: unavailable, then purged under the library's rules, with its favourites, ratings, plays and playlist entries. The CHANGELOG says so in those words.

Tests

  • tests/scanner/music_videos.rs, three tests:
    • the clip beside its song and the clip in Clips/ are dropped; an audio .mp4 beside its song, a lone video, and a video .mp4 beside a .webm of its name all stay tracks;
    • a video already indexed goes once its song is put beside it;
    • a scoped scan of Album/Clips walks Album.
  • a_scope_is_plain_folders_or_the_whole_library checks that a Clips folder becomes its parent whatever its case, that Clips at the root means the whole library, and that Clips Live is not a Clips folder.
  • Counter-checks, run locally and then restored:
    • without the drop_clips call, all three tests fail;
    • without the scope widening, the scoped scan test fails;
    • with the content check forced to true, the first test fails on Audio.mp4.
  • cargo fmt, clippy -D warnings, cargo doc -D warnings and check-rust-layout.sh pass, and cargo test --all-features runs 849 passed, 0 failed.

Summary by CodeRabbit

  • Corrections

    • Les vidéos MP4 portant le même nom qu’une chanson ne sont plus indexées comme pistes, sauf si elles contiennent uniquement de l’audio. Les vidéos sans chanson correspondante restent indexées.
    • Lorsqu’un fichier audio correspondant est ajouté, la vidéo déjà indexée est retirée au prochain scan, selon les règles de la bibliothèque.
    • Les modifications apportées à un dossier Clips déclenchent l’analyse de son dossier parent. Un dossier Clips situé à la racine entraîne l’analyse de toute la bibliothèque.
  • Documentation

    • La RFC précise quelles décisions sont partiellement implémentées et lesquelles restent à venir.

Signed-off-by: InstaZDLL <github.105mh@8shield.net>
Signed-off-by: InstaZDLL <github.105mh@8shield.net>
@github-actions github-actions Bot added scope: server Server core (Rust) scope: docs Docs, README, assets scope: scanner size: m 50-200 lines labels Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Le scanner traite un dossier Clips comme une portée visant son dossier parent. Après déduplication, il filtre les vidéos .mp4 qui partagent le nom d’une chanson et qui contiennent une piste vidéo.

Changes: Découverte des clips vidéo

Layer / File(s) Summary
Normalisation du périmètre
src/library/scanner/discovery/mod.rs, src/library/scanner/discovery/tests.rs
Un dossier terminal Clips ou clips est remplacé par son parent. Si Clips se trouve à la racine, la portée renvoie None. Les tests couvrent aussi les noms qui contiennent seulement Clips.
Filtrage des vidéos homonymes
src/library/scanner/discovery/mod.rs, tests/scanner/*, CHANGELOG.md, docs/rfcs/RFC-029-track-music-video.md
La découverte filtre les candidats .mp4 qui correspondent à une chanson et contiennent une vidéo. Les fichiers illisibles restent découverts. Les tests couvrent les exceptions, les scans ciblés sur Clips et le retrait d’une vidéo après un nouveau scan. Le changelog et la RFC documentent le périmètre des changements.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Discovery as Découverte
  participant Clips as Helper Clips du cœur
  participant Content as Contrôle du contenu
  Discovery->>Clips: Sélectionner les candidats par nom
  Clips-->>Discovery: Retourner les chemins candidats
  Discovery->>Content: Vérifier le contenu des candidats
  Content-->>Discovery: Identifier les fichiers vidéo
Loading
Merge Risk: Minimal · up to 0be8f

Music-video .mp4 files that share a name with a song are now left out of the library walk, and scans of a Clips folder cover its parent. The one residual edge case needs unusual non-UTF-8 filenames and has a narrow impact. No merge-blocking risk remains.

Security architecture risk: Low · up to 0be8f

The change preserves the inspected library boundaries and scan safeguards. Its main design risk is that previously indexed videos become unavailable and can later lose associated favourites, ratings, plays and playlist entries under existing purge rules. Reverting the code would not recover data already purged.

Retained concerns

  • Low · architecture · inferred: Previously indexed clips now enter the unavailable-and-purge lifecycle even though their files remain present. A completed purge can remove attached member data that code rollback alone cannot restore. This is a documented lifecycle tradeoff, not a verified security vulnerability.
Security review details

Security Blast Radius

  • inferred — Control over admitted media names and contents can influence clip classification and catalogue availability. The inspected transition operates on the selected library’s catalogue; a root Clips event can broaden work to that entire library. Link-enabled walks retain their existing configured target restrictions.

Trust Boundaries and Controls

  • observed — Scope normalization still rejects absolute paths, parent traversal and malformed components. Widening removes a terminal Clips component rather than traversing above the library root. Discovery retains the existing ignore, symlink and configured link-target checks.

Resilience and Maintainability Implications

  • observed — Unavailable marking is transactional with its library-change events and updates only currently available rows in the selected library and scan scope. Repeated filtering therefore does not repeatedly transition an already unavailable row. Unnamed walk failures suppress this sweep.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed Le titre « fix(scanner): leave a music video out of the walk » décrit le changement principal : les vidéos musicales en .mp4 ne sont plus indexées comme pistes audio pendant le parcours du scanner. Il…
Description check Passed La description suit le gabarit : résumé avec lien vers la RFC-029, section Changes détaillée, section de tests et notes sur l'impact sur un catalogue existant. Les sections du gabarit Test plan (comma…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

Le titre « fix(scanner): leave a music video out of the walk » décrit le changement principal : les vidéos musicales en .mp4 ne sont plus indexées comme pistes audio pendant le parcours du scanner. Il est court, précis et cohérent avec les objectifs de la PR et les modifications de découverte et de tests.

Full details: Description check

Explanation

La description suit le gabarit : résumé avec lien vers la RFC-029, section Changes détaillée, section de tests et notes sur l'impact sur un catalogue existant. Les sections du gabarit Test plan (commandes bun run typecheck, lint, format:check, build, test, smoke manuel) ne sont pas reprises telles quelles, car le dépôt Rust utilise des commandes cargo différentes. Le contenu de validation est néanmoins fourni, ce qui rend la description suffisamment complète.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 535c6c1 and 0be8f57.

Files selected for processing: 6

  • CHANGELOG.md
  • docs/rfcs/RFC-029-track-music-video.md
  • src/library/scanner/discovery/mod.rs
  • src/library/scanner/discovery/tests.rs
  • tests/scanner/main.rs
  • tests/scanner/music_videos.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

@github-actions github-actions Bot added type: fix Bug fix and removed type: fix Bug fix labels Nov 14, 2026
@InstaZDLL InstaZDLL self-assigned this Nov 14, 2026
@InstaZDLL
InstaZDLL merged commit 54f3ae2 into main Nov 14, 2026
17 checks passed
@InstaZDLL
InstaZDLL deleted the fix/scanner-music-video-not-a-track branch November 14, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: docs Docs, README, assets scope: scanner scope: server Server core (Rust) size: m 50-200 lines type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant