Fix case-insensitive lookup for series and authors during import

When importing books, the filter data cache was using case-sensitive
lookups for series and author names, while the database fallback used
case-insensitive matching. This inconsistency caused duplicate series
and authors to be created when names differed only in casing
(e.g., "Harry Potter" vs "harry potter").

Now both paths use case-insensitive comparison.

Fixes #4255

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Richard Bennion 2026-01-09 13:58:09 -08:00
parent 122fc34a75
commit 0ed641f0b1

View file

@ -624,7 +624,9 @@ class Database {
if (!this.libraryFilterData[libraryId]) {
return (await this.authorModel.getByNameAndLibrary(authorName, libraryId))?.id || null
}
return this.libraryFilterData[libraryId].authors.find((au) => au.name === authorName)?.id || null
// Case-insensitive comparison to match getByNameAndLibrary behavior
const authorNameLower = authorName.toLowerCase()
return this.libraryFilterData[libraryId].authors.find((au) => au.name.toLowerCase() === authorNameLower)?.id || null
}
/**
@ -638,7 +640,9 @@ class Database {
if (!this.libraryFilterData[libraryId]) {
return (await this.seriesModel.getByNameAndLibrary(seriesName, libraryId))?.id || null
}
return this.libraryFilterData[libraryId].series.find((se) => se.name === seriesName)?.id || null
// Case-insensitive comparison to match getByNameAndLibrary behavior
const seriesNameLower = seriesName.toLowerCase()
return this.libraryFilterData[libraryId].series.find((se) => se.name.toLowerCase() === seriesNameLower)?.id || null
}
/**