From 0ed641f0b15ed854b2aa804a143e6ce0fd91df43 Mon Sep 17 00:00:00 2001 From: Richard Bennion Date: Fri, 9 Jan 2026 13:58:09 -0800 Subject: [PATCH] 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 --- server/Database.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/Database.js b/server/Database.js index 213c2c61b..e10db72b3 100644 --- a/server/Database.js +++ b/server/Database.js @@ -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 } /**