Skip to content

fix(metadata): re-fetch titles/overviews when a library's metadata language changes - #278

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
fluxis:fix/library-language-refetch
Jul 2, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
fluxis:fix/library-language-refetch

Conversation

@fluxis

@fluxis fluxis commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An item's default_metadata_language was stamped once at first match and never updated. Changing a library's metadata language did nothing for existing items: the canonical-language pin in mergeAndPersist routed any refresh in a different language into the localization side-tables, the upserts' COALESCE kept the old stamp forever, quick-mode library refresh skipped complete items entirely, and HandleUpdateLibrary triggered nothing on a language change. Items stayed in the old language no matter how often the admin refreshed or re-matched (#211).

Approach — four coupled changes

  1. Trigger: HandleUpdateLibrary enqueues a quick library metadata refresh when the metadata language changes (mirrors the existing paths-change rescan trigger; conflict with an already-queued refresh is tolerated).
  2. Lister: quick-mode refresh includes complete items whose stamped language differs from the library's configured language — previously they were never revisited.
  3. Adoption: a folder-scoped manual refresh whose resolved library language differs from the item's stamp sets ProcessRequest.AdoptLanguage; mergeAndPersist then treats the library language as the new canonical — base-row title/overview are rewritten and the item restamped — instead of shunting the fetch into localization tables. Gated to ModeManualRefresh only: scheduled refreshes merge fill-empty and would restamp the language without rewriting the text.
  4. SQL pins: the five COALESCE clauses that made default_metadata_language write-once (media_items, seasons ×2, episodes ×2) now prefer the incoming non-empty value. Every existing caller sends the unchanged stamp or an empty string, so behavior is unchanged outside adoption — and the restamp is atomic with the successful canonical write (no mislabeled rows if a provider fetch fails mid-refresh).

Viewers preferring the old language still get localized text via the existing LocalizeItemModel overlay; the base row simply follows the library setting — which is what the setting claims to mean.

Testing

  • Unit tests on the canonical pin (adopt rewrites+restamps; without the flag the old pin behavior is preserved) and the adoption decision table.
  • DB-backed tests (SILO_TEST_DATABASE_URL) proving the upsert restamp semantics on all three tables and the quick-lister language-mismatch predicate.
  • Handler test proving the language-change trigger fires exactly once (and not on rename or same-language updates).
  • Live-validated on a production deployment: one-movie test library flipped en→da→de→en — each flip auto-enqueued the refresh job and restamped the item (default_metadata_language followed each change; this exact flow was a no-op before the fix).

Risks / notes

  • An item shared by two libraries with different languages will follow whichever library was refreshed last (previously it was pinned to first-match language forever). Deemed acceptable: the localization overlay still serves per-viewer languages.
  • ProcessRequest gains a field — additive, internal type.

Fixes #211

AI-use disclosure

Implemented with Claude Code (test-first, live-validated); human-reviewed before submission.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Library updates can now trigger a quick metadata refresh when the library language changes.
    • Manual folder refreshes can now adopt the folder’s language as the item’s main language for cleaner updates.
  • Bug Fixes

    • Quick refresh now includes items whose stored language differs from the folder language.
    • Language values are now preserved more consistently during item, season, and episode updates, avoiding unexpected resets.

…nguage changes

An item's default_metadata_language was stamped once at first match and
never updated: the canonical-language pin in mergeAndPersist routed any
refresh in a different language into the localization tables, the
upserts' COALESCE kept the old stamp forever, quick-mode library refresh
skipped complete items entirely, and changing the language in
HandleUpdateLibrary triggered nothing. Items stayed in the old language
no matter how often the admin refreshed (Silo-Server#211).

Four coupled changes:
- ProcessRequest.AdoptLanguage: folder-scoped manual refreshes adopt the
  library's language as the item's new canonical language when it
  differs from the stamp, rewriting the base row instead of localizing
  to the side. Only ModeManualRefresh adopts — scheduled refreshes merge
  fill-empty and would restamp without rewriting the text.
- Upsert language pins inverted (media_items, seasons, episodes): prefer
  the incoming non-empty default_metadata_language over the existing
  stamp. All existing callers send the unchanged stamp or empty, so
  behavior is unchanged outside adoption; the restamp is atomic with the
  canonical write.
- Quick-mode refresh lister now includes complete items whose stamp
  differs from the library's configured language.
- HandleUpdateLibrary enqueues a quick library metadata refresh when the
  metadata language changes, mirroring the paths-change rescan trigger.

Fixes Silo-Server#211

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Quick104, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c24dbbb-52db-42ce-9909-1deeb850aee3

📥 Commits

Reviewing files that changed from the base of the PR and between d4e8a1a and 4dbf2f3.

📒 Files selected for processing (3)
  • internal/metadata/relanguage_test.go
  • internal/metadata/service.go
  • internal/metadata/service_test.go
📝 Walkthrough

Walkthrough

This change addresses issue #211 by enabling library metadata language changes to trigger re-fetching of item titles/overviews. It adds language-mismatch detection in quick refresh queries, queues refresh jobs on library metadata language edits, adjusts upsert conflict precedence for default_metadata_language, and introduces an AdoptLanguage mechanism in the metadata service to rewrite canonical base-row content and restamp the language during manual refreshes.

Changes

Language adoption and refresh flow

Layer / File(s) Summary
ProcessRequest AdoptLanguage contract
internal/metadata/types.go
Adds AdoptLanguage bool field to ProcessRequest documenting canonical language rewrite behavior.
Metadata service adoption logic
internal/metadata/service.go, internal/metadata/relanguage_test.go
Adds adoptableFolderLanguage rule gate, computes adopt target for folder-scoped manual refreshes, sets AdoptLanguage per request, and prevents mergeAndPersist from overwriting canonical language when adoption is requested; tested via base-row rewrite/restamp and canonical-pin-preservation cases.
Upsert conflict precedence for default_metadata_language
internal/catalog/item_repo.go, internal/catalog/season_repo.go, internal/catalog/episode_repo.go, internal/catalog/default_language_restamp_test.go
Swaps COALESCE/NULLIF precedence in item, season, and episode upsert conflict clauses to prefer non-empty incoming values over existing stored values; validated with restamp integration tests.
Quick-refresh language mismatch detection
internal/adminjob/library_refresh.go, internal/adminjob/library_refresh_language_test.go
Joins media_folders into the quick-refresh item query and adds a predicate selecting items whose stored default metadata language differs from the folder's language, verified by an integration test.
Library update queues quick refresh on language change
internal/api/handlers/libraries.go, internal/api/handlers/libraries_language_change_test.go
HandleUpdateLibrary detects metadata language changes and queues a quick refresh job, publishing a job.created event and ignoring active-job conflicts, validated by a handler test with a fake job creator.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant HandleUpdateLibrary
  participant JobRepo
  participant EventBus
  participant MetadataService
  participant ItemRepository

  Client->>HandleUpdateLibrary: PUT update library (new metadata_language)
  HandleUpdateLibrary->>HandleUpdateLibrary: compare old vs new metadata_language
  alt language changed
    HandleUpdateLibrary->>JobRepo: CreateLibraryRefresh(quick mode)
    JobRepo-->>HandleUpdateLibrary: success or active-job conflict
    HandleUpdateLibrary->>EventBus: publish job.created (on success)
  end
  Client->>MetadataService: Process(ProcessRequest, ModeManualRefresh)
  MetadataService->>MetadataService: adoptableFolderLanguage(item stamp, folder language)
  MetadataService->>MetadataService: set AdoptLanguage on request
  MetadataService->>ItemRepository: mergeAndPersist rewritten title/overview + restamped language
Loading

Suggested labels: v1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: metadata refreshes now re-fetch titles/overviews when a library language changes.
Linked Issues check ✅ Passed The changes address #211 by triggering refreshes on library language changes and ensuring quick/manual refresh paths adopt the new language.
Out of Scope Changes check ✅ Passed All code changes support the metadata-language refresh fix and its test coverage; no unrelated functionality stands out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/api/handlers/libraries.go (1)

619-727: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the language-change trigger into a helper.

HandleUpdateLibrary now handles validation, persistence, section-title sync, language-change refresh queuing, and path-change rescanning in one function. Not blocking, but a small helper (e.g. queueRefreshOnLanguageChange) would keep the handler focused as more triggers get added here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/api/handlers/libraries.go` around lines 619 - 727,
HandleUpdateLibrary is getting too crowded with post-update side effects, so
extract the metadata-language change refresh logic into a small helper to keep
the handler focused. Move the `JobRepo.CreateLibraryRefresh` and related
conflict/warn handling into a helper such as `queueRefreshOnLanguageChange`, and
call it from `HandleUpdateLibrary` near the existing oldFolder/folder
comparison. Keep the section-title sync and path-rescan logic in the handler for
now, but make the language-change trigger self-contained for easier future
expansion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/metadata/service.go`:
- Around line 520-534: Gate the extra item lookup in service.go’s folder-scoped
adoption block so it only runs for ModeManualRefresh before calling
s.itemRepo.GetByID, and keep the adoptableFolderLanguage check as the final
validation. Also stop swallowing GetByID failures silently: if the lookup
returns an error, log or otherwise surface it so adoption failures are visible
instead of silently no-oping.

---

Nitpick comments:
In `@internal/api/handlers/libraries.go`:
- Around line 619-727: HandleUpdateLibrary is getting too crowded with
post-update side effects, so extract the metadata-language change refresh logic
into a small helper to keep the handler focused. Move the
`JobRepo.CreateLibraryRefresh` and related conflict/warn handling into a helper
such as `queueRefreshOnLanguageChange`, and call it from `HandleUpdateLibrary`
near the existing oldFolder/folder comparison. Keep the section-title sync and
path-rescan logic in the handler for now, but make the language-change trigger
self-contained for easier future expansion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c78e3aa3-0a01-4c11-841c-db04c19e0cb5

📥 Commits

Reviewing files that changed from the base of the PR and between 027b0e2 and d4e8a1a.

📒 Files selected for processing (11)
  • internal/adminjob/library_refresh.go
  • internal/adminjob/library_refresh_language_test.go
  • internal/api/handlers/libraries.go
  • internal/api/handlers/libraries_language_change_test.go
  • internal/catalog/default_language_restamp_test.go
  • internal/catalog/episode_repo.go
  • internal/catalog/item_repo.go
  • internal/catalog/season_repo.go
  • internal/metadata/relanguage_test.go
  • internal/metadata/service.go
  • internal/metadata/types.go

Comment on lines +520 to +534
// A folder-scoped manual refresh resolves exactly one language — the
// library's setting. When that differs from the item's stamped canonical
// language, adopt it so the base row is re-fetched in the library's
// language instead of the fetch being shunted into localization tables
// forever (issue #211). Adoption is decided here (not in mergeAndPersist)
// so identify/initial-match and multi-language item-scoped refreshes are
// never affected.
adoptTarget := ""
if folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
if item, err := s.itemRepo.GetByID(ctx, req.ContentID); err == nil && item != nil {
if adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
adoptTarget = languages[0]
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Gate the extra GetByID call on ModeManualRefresh before querying.

adoptableFolderLanguage immediately rejects any mode other than ModeManualRefresh, but the guard here doesn't check req.Mode before issuing s.itemRepo.GetByID. Every folder-scoped, single-language refresh — including ModeScheduledRefresh, which runs across whole libraries — now pays for an extra DB round trip that's discarded as soon as adoptableFolderLanguage checks the mode. mergeAndPersist already fetches the existing item separately for its own merge logic, so this is pure waste for non-manual modes.

Also, the GetByID error is silently swallowed (err == nil && item != nil), so transient failures cause the intended relanguage adoption to silently no-op with no trace.

🚀 Proposed fix
 	adoptTarget := ""
-	if folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
-		if item, err := s.itemRepo.GetByID(ctx, req.ContentID); err == nil && item != nil {
-			if adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
-				adoptTarget = languages[0]
-			}
-		}
-	}
+	if req.Mode == ModeManualRefresh && folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
+		item, err := s.itemRepo.GetByID(ctx, req.ContentID)
+		if err != nil {
+			slog.Warn("metadata: loading item for language adoption check failed", "content_id", req.ContentID, "error", err)
+		} else if item != nil && adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
+			adoptTarget = languages[0]
+		}
+	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// A folder-scoped manual refresh resolves exactly one language — the
// library's setting. When that differs from the item's stamped canonical
// language, adopt it so the base row is re-fetched in the library's
// language instead of the fetch being shunted into localization tables
// forever (issue #211). Adoption is decided here (not in mergeAndPersist)
// so identify/initial-match and multi-language item-scoped refreshes are
// never affected.
adoptTarget := ""
if folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
if item, err := s.itemRepo.GetByID(ctx, req.ContentID); err == nil && item != nil {
if adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
adoptTarget = languages[0]
}
}
}
// A folder-scoped manual refresh resolves exactly one language — the
// library's setting. When that differs from the item's stamped canonical
// language, adopt it so the base row is re-fetched in the library's
// language instead of the fetch being shunted into localization tables
// forever (issue `#211`). Adoption is decided here (not in mergeAndPersist)
// so identify/initial-match and multi-language item-scoped refreshes are
// never affected.
adoptTarget := ""
if req.Mode == ModeManualRefresh && folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
item, err := s.itemRepo.GetByID(ctx, req.ContentID)
if err != nil {
slog.Warn("metadata: loading item for language adoption check failed", "content_id", req.ContentID, "error", err)
} else if item != nil && adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
adoptTarget = languages[0]
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/metadata/service.go` around lines 520 - 534, Gate the extra item
lookup in service.go’s folder-scoped adoption block so it only runs for
ModeManualRefresh before calling s.itemRepo.GetByID, and keep the
adoptableFolderLanguage check as the final validation. Also stop swallowing
GetByID failures silently: if the lookup returns an error, log or otherwise
surface it so adoption failures are visible instead of silently no-oping.

@Quick104

Quick104 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Code review

Found 2 issues:

  1. Locked title/overview fields defeat the adoption restamp. In mergeAndPersist, item.DefaultMetadataLanguage = canonicalLanguage is applied unconditionally when AdoptLanguage is set, while the title/overview merges above are gated per-field by isFieldLocked. An item with a locked title keeps its old-language text but gets restamped to the new language, so the quick-refresh mismatch predicate in library_refresh.go never flags it again — it's permanently mislabeled. Consider only restamping when the language-bearing fields were actually adoptable, or accepting the restamp deliberately with a comment. (bug)

ApplyDefaultSortTitle(accumulator, isFieldLocked(locked, FieldName))
// Build the item for persistence.
now := time.Now()
item := metadataResultToItem(accumulator, contentType)
item.DefaultMetadataLanguage = canonicalLanguage
item.MatchedAt = &now

  1. Shared items flip-flop between libraries with different languages. media_item_libraries allows one item in multiple libraries, but the adoption gate (adoptableFolderLanguage + single-language resolution) only looks at the requesting folder's library. An item in library A (en) and library B (de) will have its canonical base-row title/overview rewritten to whichever library's refresh ran last, oscillating on every language-change refresh instead of settling on a stable canonical language. (bug)

if folderID > 0 && req.ContentID != "" && len(languages) == 1 && s.itemRepo != nil {
if item, err := s.itemRepo.GetByID(ctx, req.ContentID); err == nil && item != nil {
if adoptableFolderLanguage(req.Mode, item.DefaultMetadataLanguage, languages[0]) {
adoptTarget = languages[0]
}
}
}
var final ProcessResult
for _, language := range languages {
langReq := req
langReq.Language = language
langReq.AdoptLanguage = adoptTarget != "" && strings.EqualFold(language, adoptTarget)
result, err := s.processInternal(ctx, langReq, resolveChain)

Also noting (minor, likely acceptable scoping): refreshSeriesChildTarget still pins season/episode-scoped manual refreshes to series.DefaultMetadataLanguage without the adoption logic, so a manual season/episode refresh racing ahead of the automatic library-wide refresh still writes the old language; it self-heals once the series is restamped.

The COALESCE inversions checked out: applied consistently across all three repos, no historical fix is being reverted (the old direction dates to the initial migration), and every existing caller sends either the unchanged stamp or empty, matching the commit message's claim.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

…ement

Two hardening fixes for AdoptLanguage from review of Silo-Server#278:

- Locked fields defeat the restamp: title/overview merges honor per-field
  locks, but the restamp was unconditional. An item with both language-
  bearing fields locked kept its old-language text yet got stamped the
  new language, so the quick-refresh mismatch predicate never flagged it
  again. mergeAndPersist now skips adoption when both name and overview
  are locked, falling back to the non-adopting behavior: the stamp stays
  put, isCanonicalWrite goes false, and the fetch routes to the
  localization tables exactly like a non-adopting refresh in that
  language does today. One locked field still adopts — the other is
  actually rewritten.

- Multi-library flip-flop: an item in libraries with different metadata
  languages had its canonical base row rewritten to whichever library
  refreshed last, oscillating forever. Process now requires every
  library containing the item (media_item_libraries) to resolve to the
  adoption target before setting AdoptLanguage, via the existing
  GetDistinctMetadataLanguagesForItem (which applies the same empty→en
  default as resolveFolderLanguage). Disagreement or a lookup failure
  keeps the current stamp — stable beats flip-flopping.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Quick104

Quick104 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Addressed both review findings in 4dbf2f3:

  • Locked fields: mergeAndPersist now skips the language restamp when both title and overview are field-locked (a single locked field still adopts, since the other is genuinely rewritten). The skipped case falls back to the existing stamp, so isCanonicalWrite routes the fetch into the localization tables exactly like a non-adopting refresh does today.
  • Multi-library flip-flop: adoption in Process is now additionally gated on itemLibrariesAgreeOnLanguage, reusing the existing GetDistinctMetadataLanguagesForItem query (which applies the same empty→en default as resolveFolderLanguage). Libraries that disagree, lookup errors, or a nil repo all skip adoption and keep the stable stamp.

New tests cover both-locked (stamp unchanged), title-only-locked (stamp adopted, locked title preserved), and a table test for the agreement gate. All metadata/adminjob/catalog tests pass, including the DB-backed restamp tests against a real migrated scratch Postgres.

🤖 Generated with Claude Code

@Quick104
Quick104 merged commit 3d8a63d into Silo-Server:main Jul 2, 2026
1 check passed
Quick104 added a commit to RXWatcher/silo-server that referenced this pull request Jul 10, 2026
…nguage changes (Silo-Server#278)

* fix(metadata): re-fetch titles/overviews when a library's metadata language changes

An item's default_metadata_language was stamped once at first match and
never updated: the canonical-language pin in mergeAndPersist routed any
refresh in a different language into the localization tables, the
upserts' COALESCE kept the old stamp forever, quick-mode library refresh
skipped complete items entirely, and changing the language in
HandleUpdateLibrary triggered nothing. Items stayed in the old language
no matter how often the admin refreshed (Silo-Server#211).

Four coupled changes:
- ProcessRequest.AdoptLanguage: folder-scoped manual refreshes adopt the
  library's language as the item's new canonical language when it
  differs from the stamp, rewriting the base row instead of localizing
  to the side. Only ModeManualRefresh adopts — scheduled refreshes merge
  fill-empty and would restamp without rewriting the text.
- Upsert language pins inverted (media_items, seasons, episodes): prefer
  the incoming non-empty default_metadata_language over the existing
  stamp. All existing callers send the unchanged stamp or empty, so
  behavior is unchanged outside adoption; the restamp is atomic with the
  canonical write.
- Quick-mode refresh lister now includes complete items whose stamp
  differs from the library's configured language.
- HandleUpdateLibrary enqueues a quick library metadata refresh when the
  metadata language changes, mirroring the paths-change rescan trigger.

Fixes Silo-Server#211

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(metadata): gate language adoption on field locks and library agreement

Two hardening fixes for AdoptLanguage from review of Silo-Server#278:

- Locked fields defeat the restamp: title/overview merges honor per-field
  locks, but the restamp was unconditional. An item with both language-
  bearing fields locked kept its old-language text yet got stamped the
  new language, so the quick-refresh mismatch predicate never flagged it
  again. mergeAndPersist now skips adoption when both name and overview
  are locked, falling back to the non-adopting behavior: the stamp stays
  put, isCanonicalWrite goes false, and the fetch routes to the
  localization tables exactly like a non-adopting refresh in that
  language does today. One locked field still adopts — the other is
  actually rewritten.

- Multi-library flip-flop: an item in libraries with different metadata
  languages had its canonical base row rewritten to whichever library
  refreshed last, oscillating forever. Process now requires every
  library containing the item (media_item_libraries) to resolve to the
  adoption target before setting AdoptLanguage, via the existing
  GetDistinctMetadataLanguagesForItem (which applies the same empty→en
  default as resolveFolderLanguage). Disagreement or a lookup failure
  keeps the current stamp — stable beats flip-flopping.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Quick <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1.0 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Changing a library's metadata language doesn't re-fetch titles/overviews

2 participants