Skip to content

Commit 50bd264

Browse files
committed
Fix:Server crash on matching book with an author name ending in comma #2796
1 parent f9b95bb commit 50bd264

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

client/components/modals/item/tabs/Match.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,10 @@ export default {
508508
} else if (key === 'author' && !this.isPodcast) {
509509
var authors = this.selectedMatch[key]
510510
if (!Array.isArray(authors)) {
511-
authors = authors.split(',').map((au) => au.trim())
511+
authors = authors
512+
.split(',')
513+
.map((au) => au.trim())
514+
.filter((au) => !!au)
512515
}
513516
var authorPayload = []
514517
authors.forEach((authorName) =>

server/routers/ApiRouter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ class ApiRouter {
531531
const authorName = (mediaMetadata.authors[i].name || '').trim()
532532
if (!authorName) {
533533
Logger.error(`[ApiRouter] Invalid author object, no name`, mediaMetadata.authors[i])
534+
mediaMetadata.authors[i].id = null
534535
continue
535536
}
536537

@@ -559,6 +560,8 @@ class ApiRouter {
559560
mediaMetadata.authors[i].id = author.id
560561
}
561562
}
563+
// Remove authors without an id
564+
mediaMetadata.authors = mediaMetadata.authors.filter(au => !!au.id)
562565
if (newAuthors.length) {
563566
await Database.createBulkAuthors(newAuthors)
564567
SocketAuthority.emitter('authors_added', newAuthors.map(au => au.toJSON()))
@@ -572,6 +575,7 @@ class ApiRouter {
572575
const seriesName = (mediaMetadata.series[i].name || '').trim()
573576
if (!seriesName) {
574577
Logger.error(`[ApiRouter] Invalid series object, no name`, mediaMetadata.series[i])
578+
mediaMetadata.series[i].id = null
575579
continue
576580
}
577581

@@ -600,6 +604,8 @@ class ApiRouter {
600604
mediaMetadata.series[i].id = seriesItem.id
601605
}
602606
}
607+
// Remove series without an id
608+
mediaMetadata.series = mediaMetadata.series.filter(se => se.id)
603609
if (newSeries.length) {
604610
await Database.createBulkSeries(newSeries)
605611
SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON()))

0 commit comments

Comments
 (0)