The key change: Move the Database.bookAuthorModel.create() block outside the if (!author) check,

so it runs whether the author was just created OR already existed in the database.

This bug was visible when using "Match Books" for a library and the outcome was books had no author(s) assigned
despite the custom providers correctly providing those values.
This commit is contained in:
Tomasz N.
2025-10-22 23:02:49 +02:00
parent 0c7b738b7c
commit a5750deaaf

View File

@@ -259,7 +259,7 @@ class Scanner {
SocketAuthority.emitter('author_added', author.toOldJSON())
// Update filter data
Database.addAuthorToFilterData(libraryItem.libraryId, author.name, author.id)
}
await Database.bookAuthorModel
.create({
authorId: author.id,
@@ -270,7 +270,6 @@ class Scanner {
libraryItem.media.authors.push(author)
hasAuthorUpdates = true
})
}
}
const authorsRemoved = libraryItem.media.authors.filter((a) => !matchData.author.find((ma) => ma.toLowerCase() === a.name.toLowerCase()))
if (authorsRemoved.length) {