mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-22 00:07:52 +01:00
Fix:Server crash on scan for library with no metadataPrecedence set #3434
This commit is contained in:
parent
2f49a08c7d
commit
22ad16e11b
@ -70,11 +70,15 @@ class Library extends Model {
|
||||
epubsAllowScriptedContent: false,
|
||||
hideSingleBookSeries: false,
|
||||
onlyShowLaterBooksInContinueSeries: false,
|
||||
metadataPrecedence: ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
|
||||
metadataPrecedence: this.defaultMetadataPrecedence
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static get defaultMetadataPrecedence() {
|
||||
return ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Library[]>}
|
||||
|
@ -655,7 +655,7 @@ class BookScanner {
|
||||
}
|
||||
|
||||
const bookMetadataSourceHandler = new BookScanner.BookMetadataSourceHandler(bookMetadata, audioFiles, ebookFileScanData, libraryItemData, libraryScan, existingLibraryItemId)
|
||||
const metadataPrecedence = librarySettings.metadataPrecedence || ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
|
||||
const metadataPrecedence = librarySettings.metadataPrecedence || Database.libraryModel.defaultMetadataPrecedence
|
||||
libraryScan.addLog(LogLevel.DEBUG, `"${bookMetadata.title}" Getting metadata with precedence [${metadataPrecedence.join(', ')}]`)
|
||||
for (const metadataSource of metadataPrecedence) {
|
||||
if (bookMetadataSourceHandler[metadataSource]) {
|
||||
|
@ -59,9 +59,10 @@ class LibraryScanner {
|
||||
return
|
||||
}
|
||||
|
||||
if (library.isBook && library.settings.metadataPrecedence.join() !== library.lastScanMetadataPrecedence.join()) {
|
||||
const metadataPrecedence = library.settings.metadataPrecedence || Database.libraryModel.defaultMetadataPrecedence
|
||||
if (library.isBook && metadataPrecedence.join() !== library.lastScanMetadataPrecedence.join()) {
|
||||
const lastScanMetadataPrecedence = library.lastScanMetadataPrecedence?.join() || 'Unset'
|
||||
Logger.info(`[LibraryScanner] Library metadata precedence changed since last scan. From [${lastScanMetadataPrecedence}] to [${library.settings.metadataPrecedence.join()}]`)
|
||||
Logger.info(`[LibraryScanner] Library metadata precedence changed since last scan. From [${lastScanMetadataPrecedence}] to [${metadataPrecedence.join()}]`)
|
||||
forceRescan = true
|
||||
}
|
||||
|
||||
@ -90,7 +91,7 @@ class LibraryScanner {
|
||||
library.lastScanVersion = packageJson.version
|
||||
if (library.isBook) {
|
||||
const newExtraData = library.extraData || {}
|
||||
newExtraData.lastScanMetadataPrecedence = library.settings.metadataPrecedence
|
||||
newExtraData.lastScanMetadataPrecedence = metadataPrecedence
|
||||
library.extraData = newExtraData
|
||||
library.changed('extraData', true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user