Fix:Server crash when updating media with external cover url that fails to download #2857

This commit is contained in:
advplyr 2024-04-20 11:34:21 -05:00
parent 15f83986e7
commit f74d741821

View File

@ -117,16 +117,20 @@ class LibraryItemController {
zipHelpers.zipDirectoryPipe(libraryItemPath, filename, res) zipHelpers.zipDirectoryPipe(libraryItemPath, filename, res)
} }
// /**
// PATCH: will create new authors & series if in payload * PATCH: /items/:id/media
// * Update media for a library item. Will create new authors & series when necessary
*
* @param {import('express').Request} req
* @param {import('express').Response} res
*/
async updateMedia(req, res) { async updateMedia(req, res) {
const libraryItem = req.libraryItem const libraryItem = req.libraryItem
const mediaPayload = req.body const mediaPayload = req.body
if (mediaPayload.url) { if (mediaPayload.url) {
await LibraryItemController.prototype.uploadCover.bind(this)(req, res, false) await LibraryItemController.prototype.uploadCover.bind(this)(req, res, false)
if (res.writableEnded) return if (res.writableEnded || res.headersSent) return
} }
// Book specific // Book specific