Fix author order when scanning in multi-author books by setting bookAuthor.createdAt when bulk creating #4177

This commit is contained in:
advplyr 2025-04-03 17:50:10 -05:00
parent ca7388b14e
commit c7faafd0f3

View file

@ -475,6 +475,8 @@ class BookScanner {
bookAuthors: [], bookAuthors: [],
bookSeries: [] bookSeries: []
} }
const createdAtTimestamp = new Date().getTime()
if (bookMetadata.authors.length) { if (bookMetadata.authors.length) {
for (const authorName of bookMetadata.authors) { for (const authorName of bookMetadata.authors) {
const matchingAuthorId = await Database.getAuthorIdByName(libraryItemData.libraryId, authorName) const matchingAuthorId = await Database.getAuthorIdByName(libraryItemData.libraryId, authorName)
@ -485,6 +487,8 @@ class BookScanner {
} else { } else {
// New author // New author
bookObject.bookAuthors.push({ bookObject.bookAuthors.push({
// Ensures authors are in a set order
createdAt: createdAtTimestamp + bookObject.bookAuthors.length,
author: { author: {
libraryId: libraryItemData.libraryId, libraryId: libraryItemData.libraryId,
name: authorName, name: authorName,