mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-06 00:16:02 +01:00
Fix:Server crash on matching book with an author name ending in comma #2796
This commit is contained in:
parent
f9b95bb003
commit
50bd2648aa
@ -508,7 +508,10 @@ export default {
|
|||||||
} else if (key === 'author' && !this.isPodcast) {
|
} else if (key === 'author' && !this.isPodcast) {
|
||||||
var authors = this.selectedMatch[key]
|
var authors = this.selectedMatch[key]
|
||||||
if (!Array.isArray(authors)) {
|
if (!Array.isArray(authors)) {
|
||||||
authors = authors.split(',').map((au) => au.trim())
|
authors = authors
|
||||||
|
.split(',')
|
||||||
|
.map((au) => au.trim())
|
||||||
|
.filter((au) => !!au)
|
||||||
}
|
}
|
||||||
var authorPayload = []
|
var authorPayload = []
|
||||||
authors.forEach((authorName) =>
|
authors.forEach((authorName) =>
|
||||||
|
@ -531,6 +531,7 @@ class ApiRouter {
|
|||||||
const authorName = (mediaMetadata.authors[i].name || '').trim()
|
const authorName = (mediaMetadata.authors[i].name || '').trim()
|
||||||
if (!authorName) {
|
if (!authorName) {
|
||||||
Logger.error(`[ApiRouter] Invalid author object, no name`, mediaMetadata.authors[i])
|
Logger.error(`[ApiRouter] Invalid author object, no name`, mediaMetadata.authors[i])
|
||||||
|
mediaMetadata.authors[i].id = null
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,6 +560,8 @@ class ApiRouter {
|
|||||||
mediaMetadata.authors[i].id = author.id
|
mediaMetadata.authors[i].id = author.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Remove authors without an id
|
||||||
|
mediaMetadata.authors = mediaMetadata.authors.filter(au => !!au.id)
|
||||||
if (newAuthors.length) {
|
if (newAuthors.length) {
|
||||||
await Database.createBulkAuthors(newAuthors)
|
await Database.createBulkAuthors(newAuthors)
|
||||||
SocketAuthority.emitter('authors_added', newAuthors.map(au => au.toJSON()))
|
SocketAuthority.emitter('authors_added', newAuthors.map(au => au.toJSON()))
|
||||||
@ -572,6 +575,7 @@ class ApiRouter {
|
|||||||
const seriesName = (mediaMetadata.series[i].name || '').trim()
|
const seriesName = (mediaMetadata.series[i].name || '').trim()
|
||||||
if (!seriesName) {
|
if (!seriesName) {
|
||||||
Logger.error(`[ApiRouter] Invalid series object, no name`, mediaMetadata.series[i])
|
Logger.error(`[ApiRouter] Invalid series object, no name`, mediaMetadata.series[i])
|
||||||
|
mediaMetadata.series[i].id = null
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,6 +604,8 @@ class ApiRouter {
|
|||||||
mediaMetadata.series[i].id = seriesItem.id
|
mediaMetadata.series[i].id = seriesItem.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Remove series without an id
|
||||||
|
mediaMetadata.series = mediaMetadata.series.filter(se => se.id)
|
||||||
if (newSeries.length) {
|
if (newSeries.length) {
|
||||||
await Database.createBulkSeries(newSeries)
|
await Database.createBulkSeries(newSeries)
|
||||||
SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON()))
|
SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON()))
|
||||||
|
Loading…
Reference in New Issue
Block a user