Unify media_key and item_key — use item_key everywhere
media_key was a lossy shortening of item_key (libraryId:lastSegment) that introduced a real collision bug: two TV episodes from different series with the same filename would share the same media_key and each other's tags. - DB migration converts existing media_tags rows from short format to full item_key by joining against media_items; ambiguous/orphaned rows are dropped - media_tags column renamed media_key → item_key - Removed itemKeyToMediaKey() from scanner; reconcileAndPrune now passes item_key directly to reKeyMediaItem - DB reader functions (tv, movies, games) now expose item_key on returned entities; frontend components use entity.item_key instead of constructing the short libraryId:id form - MixedView now constructs the full mixed_file: item_key format - Tag API renamed mediaKey param → itemKey throughout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -215,6 +215,7 @@ export function tvSeriesFromDb(libraryId: string): TvSeries[] {
|
||||
const idPart = row.item_key.split(':tv_series:')[1] ?? row.item_key
|
||||
return {
|
||||
id: idPart,
|
||||
item_key: row.item_key,
|
||||
title: row.title ?? decodeURIComponent(idPart),
|
||||
year: row.year ?? null,
|
||||
plot: row.plot ?? null,
|
||||
@@ -242,6 +243,7 @@ export function tvSeasonsFromDb(libraryId: string, seriesId: string): TvSeason[]
|
||||
const seasonId = parts[1]?.split(':').slice(1).join(':') ?? row.item_key
|
||||
return {
|
||||
id: seasonId,
|
||||
item_key: row.item_key,
|
||||
seriesId,
|
||||
title: row.title ?? seasonId,
|
||||
seasonNumber: meta.seasonNumber ?? null,
|
||||
@@ -276,6 +278,7 @@ export function tvEpisodesFromDb(
|
||||
const episodeId = suffix.split(':').slice(2).join(':')
|
||||
return {
|
||||
id: episodeId,
|
||||
item_key: row.item_key,
|
||||
title: row.title ?? decodeURIComponent(episodeId),
|
||||
episodeNumber: meta.episodeNumber ?? null,
|
||||
seasonNumber: meta.seasonNumber ?? null,
|
||||
|
||||
Reference in New Issue
Block a user