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