mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-06 22:19:04 +01:00
Fix bug with creating new series & authors on scan
This commit is contained in:
parent
c9ea5dd2d7
commit
3d2bbc7719
@ -93,6 +93,8 @@ class Scanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.createNewAuthorsAndSeries(libraryItem)
|
||||||
|
|
||||||
if (!libraryItem.hasMediaEntities) { // Library Item is invalid
|
if (!libraryItem.hasMediaEntities) { // Library Item is invalid
|
||||||
libraryItem.setInvalid()
|
libraryItem.setInvalid()
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
@ -289,6 +291,12 @@ class Scanner {
|
|||||||
var itemsUpdated = await Promise.all(itemDataToRescan.map((lid) => {
|
var itemsUpdated = await Promise.all(itemDataToRescan.map((lid) => {
|
||||||
return this.rescanLibraryItem(lid, libraryScan)
|
return this.rescanLibraryItem(lid, libraryScan)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
for (const libraryItem of itemsUpdated) {
|
||||||
|
// Temp authors & series are inserted - create them if found
|
||||||
|
await this.createNewAuthorsAndSeries(libraryItem)
|
||||||
|
}
|
||||||
|
|
||||||
itemsUpdated = itemsUpdated.filter(li => li) // Filter out nulls
|
itemsUpdated = itemsUpdated.filter(li => li) // Filter out nulls
|
||||||
if (itemsUpdated.length) {
|
if (itemsUpdated.length) {
|
||||||
libraryScan.resultsUpdated += itemsUpdated.length
|
libraryScan.resultsUpdated += itemsUpdated.length
|
||||||
@ -302,6 +310,12 @@ class Scanner {
|
|||||||
return this.scanNewLibraryItem(lid, libraryScan.libraryMediaType, libraryScan.preferAudioMetadata, libraryScan.preferOpfMetadata, libraryScan.findCovers, libraryScan)
|
return this.scanNewLibraryItem(lid, libraryScan.libraryMediaType, libraryScan.preferAudioMetadata, libraryScan.preferOpfMetadata, libraryScan.findCovers, libraryScan)
|
||||||
}))
|
}))
|
||||||
newLibraryItems = newLibraryItems.filter(li => li) // Filter out nulls
|
newLibraryItems = newLibraryItems.filter(li => li) // Filter out nulls
|
||||||
|
|
||||||
|
for (const libraryItem of newLibraryItems) {
|
||||||
|
// Temp authors & series are inserted - create them if found
|
||||||
|
await this.createNewAuthorsAndSeries(libraryItem)
|
||||||
|
}
|
||||||
|
|
||||||
libraryScan.resultsAdded += newLibraryItems.length
|
libraryScan.resultsAdded += newLibraryItems.length
|
||||||
await this.db.insertLibraryItems(newLibraryItems)
|
await this.db.insertLibraryItems(newLibraryItems)
|
||||||
this.emitter('items_added', newLibraryItems.map(li => li.toJSONExpanded()))
|
this.emitter('items_added', newLibraryItems.map(li => li.toJSONExpanded()))
|
||||||
@ -343,9 +357,6 @@ class Scanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temp authors & series are inserted - create them if found
|
|
||||||
await this.createNewAuthorsAndSeries(libraryItem)
|
|
||||||
|
|
||||||
if (!libraryItem.hasMediaEntities) { // Library item is invalid
|
if (!libraryItem.hasMediaEntities) { // Library item is invalid
|
||||||
libraryItem.setInvalid()
|
libraryItem.setInvalid()
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
@ -398,15 +409,14 @@ class Scanner {
|
|||||||
var updatedCover = await this.searchForCover(libraryItem, libraryScan)
|
var updatedCover = await this.searchForCover(libraryItem, libraryScan)
|
||||||
libraryItem.media.updateLastCoverSearch(updatedCover)
|
libraryItem.media.updateLastCoverSearch(updatedCover)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temp authors & series are inserted - create them if found
|
|
||||||
await this.createNewAuthorsAndSeries(libraryItem)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return libraryItem
|
return libraryItem
|
||||||
}
|
}
|
||||||
|
|
||||||
async createNewAuthorsAndSeries(libraryItem) {
|
async createNewAuthorsAndSeries(libraryItem) {
|
||||||
|
if (libraryItem.mediaType !== 'book') return
|
||||||
|
|
||||||
// Create or match all new authors and series
|
// Create or match all new authors and series
|
||||||
if (libraryItem.media.metadata.authors.some(au => au.id.startsWith('new'))) {
|
if (libraryItem.media.metadata.authors.some(au => au.id.startsWith('new'))) {
|
||||||
var newAuthors = []
|
var newAuthors = []
|
||||||
@ -559,6 +569,7 @@ class Scanner {
|
|||||||
Logger.debug(`[Scanner] Folder update group must be a new item "${itemDir}" in library "${library.name}"`)
|
Logger.debug(`[Scanner] Folder update group must be a new item "${itemDir}" in library "${library.name}"`)
|
||||||
var newLibraryItem = await this.scanPotentialNewLibraryItem(library.mediaType, folder, fullPath)
|
var newLibraryItem = await this.scanPotentialNewLibraryItem(library.mediaType, folder, fullPath)
|
||||||
if (newLibraryItem) {
|
if (newLibraryItem) {
|
||||||
|
await this.createNewAuthorsAndSeries(newLibraryItem)
|
||||||
await this.db.insertLibraryItem(newLibraryItem)
|
await this.db.insertLibraryItem(newLibraryItem)
|
||||||
this.emitter('item_added', newLibraryItem.toJSONExpanded())
|
this.emitter('item_added', newLibraryItem.toJSONExpanded())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user