mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-31 00:05:27 +02:00
Fix:Server crash on matching book with an author name ending in comma #2796
This commit is contained in:
parent
f9b95bb003
commit
50bd2648aa
2 changed files with 10 additions and 1 deletions
|
@ -531,6 +531,7 @@ class ApiRouter {
|
|||
const authorName = (mediaMetadata.authors[i].name || '').trim()
|
||||
if (!authorName) {
|
||||
Logger.error(`[ApiRouter] Invalid author object, no name`, mediaMetadata.authors[i])
|
||||
mediaMetadata.authors[i].id = null
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -559,6 +560,8 @@ class ApiRouter {
|
|||
mediaMetadata.authors[i].id = author.id
|
||||
}
|
||||
}
|
||||
// Remove authors without an id
|
||||
mediaMetadata.authors = mediaMetadata.authors.filter(au => !!au.id)
|
||||
if (newAuthors.length) {
|
||||
await Database.createBulkAuthors(newAuthors)
|
||||
SocketAuthority.emitter('authors_added', newAuthors.map(au => au.toJSON()))
|
||||
|
@ -572,6 +575,7 @@ class ApiRouter {
|
|||
const seriesName = (mediaMetadata.series[i].name || '').trim()
|
||||
if (!seriesName) {
|
||||
Logger.error(`[ApiRouter] Invalid series object, no name`, mediaMetadata.series[i])
|
||||
mediaMetadata.series[i].id = null
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -600,6 +604,8 @@ class ApiRouter {
|
|||
mediaMetadata.series[i].id = seriesItem.id
|
||||
}
|
||||
}
|
||||
// Remove series without an id
|
||||
mediaMetadata.series = mediaMetadata.series.filter(se => se.id)
|
||||
if (newSeries.length) {
|
||||
await Database.createBulkSeries(newSeries)
|
||||
SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue