One sidecar per language, enforced in the schema #222
Closed
opened 2026-08-25 02:51:24 +01:00 by naps62-yolo
·
1 comment
No Branch/Tag Specified
main
ui-mobile-first
codex/fix-action-button-reload
translation
qbit-2
docker
bugs
blitz/subtitles
fix/255-provider-reorder
blitz/feedback-3
subtitles/251-icon-vocab
subtitles/237-relocate-subs
fix/248-title-move-creates-root
blitz/feedback-2
issue/227-abandoned-pack-visible
issue/245-backoff-anchor
issue/240-design-coherence
issue/211-waived-rule
issue/232-plainer-words
issue/246-policy-reclassify
issue/244-root-slash-stored
issue/231-settings-rows
issue/241-reclassify-on-root-change
issue/239-failure-window
issue/230-icon-only
issue/243-root-path-edges
issue/238-attention-liveness
issue/229-back-button
issue/236-root-path-move
issue/226-attention-threshold
issue/228-root-move
blitz/size-bands
size-bands/209-runtime-scale
size-bands/210-size-waiver
size-bands/208-runtime-design
blitz/reliability
reliability/155-sqlx-migrations
reliability/176-refresh-on-add
removal-nav/175-removal-controls
removal-nav/174-season-file-removal
removal-nav/172-search-titles
removal-nav/173-homepage-library
removal-nav/171-untrack-clears
removal-nav/170-chip-align
removal-nav/169-design-amendment
feedback/167-deck-autosearch
feedback/165-chip-colour
feedback/166-header-rail
feedback/163-drop-cast
feedback/164-control-geometry
feedback/162-season-ordering
feedback/161-search-episodes
feedback/160-autotrack-seed
feedback/159-design-amend
blitz/rich-metadata
rich/151-grid
rich/148-search-rows
rich/150-series-meta
rich/149-movie-page
rich/147-search-art
rich/156-rating-null
rich/146-meta-api
rich/145-poster-cols
rich/144-trailer
rich/143-meta-detail
rich/142-design-amend
blitz/153-empty-episode-titles
blitz/152-deck-routes
blitz/141-season-vanished-api
blitz/129-series-detail-view
blitz/140-attention-episode-numbers
blitz/137-season-removals
blitz/133-attention-tv-lanes
blitz/139-movie-id-episode-guard
blitz/134-stale-attention-queue
blitz/124-rss-episode-matching
blitz/136-imdb-series-lookup
blitz/132-manual-commands
blitz/128-series-delete-files
blitz/131-status-seasons-input
blitz/138-plural-season-range
blitz/135-pack-name-parse
blitz/122-upstream-removals
blitz/130-add-series-search
blitz/121-series-refresh
blitz/127-unified-search-tv
blitz/123-episode-matching
blitz/126-tv-attention
blitz/119-tracked-rule
blitz/125-season-deck
blitz/120-tvdb-id
blitz/118-season-zero
blitz/117-design-amend
issue/115-avail-search
issue/112-name-truncate
issue/111-score-colors
No results found.
Labels
Clear labels
area/api
area/ci
area/compat
area/core
area/daemon
area/db
area/dl
area/indexer
area/infra
area/meta
area/parse
area/probe
area/subs
area/web
difficulty/easy
difficulty/hard
difficulty/moderate
difficulty/trivial
phase/1-skeleton
phase/2-logic
phase/3-sourcing
phase/4-movies
phase/5-ui
phase/6-tv
phase/7-people
phase/8-compat
phase/9-subtitles
type/bug
type/chore
type/feature
type/test
arr-api
CI and test harness
arr-compat
arr-core
arr-daemon
arr-db
arr-dl
arr-indexer
workspace and tooling
arr-meta
arr-parse
arr-probe
arr-subs crate: providers, extraction, translation, sync
web/
bounded, obvious approach, few files
subtle correctness or cross-cutting
multiple files, judgement, an interface to design
one file, mechanical, no design decisions
workspace, CI, config, database, empty API and SPA
parsing and policy engine, pure, no network
TMDB and Prowlarr, read-only
movies end to end
search, buckets, library views, queues
seasons, episodes, tracking, derived status
owner tags and notifications
Jellyseerr shim
build order: subtitles, DESIGN.md §15
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: yolo/arr#222
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Decided by the operator; DESIGN.md §15 amended in
ab001b5. Implement that.No filename segment for forced or SDH. A language is satisfied by exactly one
sidecar. Where a plain subtitle exists for a language, a forced one is
ignored rather than kept beside it.
.mtremains the only optional segment.That settles the constraint this issue was blocked on.
What to do
0029— this number is yours; #220 takes0028. AddUNIQUE (media_file_id, language)over sidecar rows — the ones with a path,i.e.
WHERE path IS NOT NULL. Embedded rows keep their existing(media_file_id, language, forced, sdh)key: they describe tracks insidethe video, not files, and several can legitimately coexist.
the path check. The migration must resolve them rather than fail: keep the
non-machine-translation row, and of two of the same kind the newest, and
delete the rest. Leave the files on disk — deleting a viewer's subtitle
during a migration is worse than an orphan, and #218's delete path can clean
up afterwards.
claim_pathis no longer the thing preventingduplicates. Keep it — it still stops two rows racing for one filename — but
the 409 on a second grab for a satisfied language should now come from the
invariant, with a message saying the language already has a subtitle and
naming the manual delete as the way to replace it (#223 ships that button).
ranking (§15, #185), so nothing should be trying to write one. Add a test
proving a forced candidate never produces a sidecar row.
Depends on: #186, #203, #218, #223
Settle forced/SDH sidecar naming and constrain itto One sidecar per language, enforced in the schemaImplemented on
subtitles/222-one-sidecar.just cipassed locally (712 tests).Migration
0029_one_sidecar_per_language.sqladdsUNIQUE (media_file_id, language) WHERE path IS NOT NULL, leaving the embedded key(media_file_id, language, forced, sdh)alone. Before creating it, the migration resolves duplicates an older database may hold: per (media file, language) it keeps a real subtitle over a machine translation, and of two of the same kind the newest, deleting only the rows — the files stay on disk for the manual delete to clean up.record_fileno longer swallows every conflict; it names the two conflict targets that mean "arr already knows this file", so the one-sidecar violation raises instead of resolving to some other row's id. The API gainedclaim_language, called by both grab and translate before anything is downloaded or written: it returns 409 naming the existing sidecar and saying to delete it first. That covers the caseclaim_pathcannot see — a language held by a.mt.srtwhile a provider fetch would write.srt.claim_pathstays, as the issue asks, for twomedia_filesrows deriving one filename from different ids.Tests added: the schema refuses a second sidecar per language while embedded tracks still share one;
sidecar_foranswers with the file and not the track; migration0029's own SQL, pulled fromMIGRATOR, resolves a seeded duplicate the way the rule says; the API refuses a grab for a language a translation already satisfies and writes nothing to disk; and the reconcile loop turns a hash-matched, heavily-downloaded forced candidate into no sidecar row and no file, landing onunavailable.Findings
crates/arr-api/src/subtitles.rsstill acceptsforced: trueonPOST /api/media-files/{id}/subtitles/grab, and writes it to<video>.<lang>.srt— the same name a plain subtitle uses. With §15 amended so forced gets no sidecar of its own and never satisfies a want, a forced manual grab now either takes the only sidecar slot a language has or is refused by the new invariant. The flag and the testa_forced_grab_is_recorded_without_satisfying_the_languagepredate the amendment. Worth deciding whether the API should still offer it at all; I left it alone rather than widen this issue.subtitle_files.pathis the row's identity on disk but nothing keeps it in step with a move: §7.4 renames on import and library moves rewritemedia_files.path, and the sidecar rows keep pointing at the old folder. Not new here, and not something this issue touches.