Skip to content

Commit

Permalink
Fix:Server crash when updating media with external cover url that fai…
Browse files Browse the repository at this point in the history
…ls to download #2857
  • Loading branch information
advplyr committed Apr 20, 2024
1 parent 15f8398 commit f74d741
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/controllers/LibraryItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,20 @@ class LibraryItemController {
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) {
const libraryItem = req.libraryItem
const mediaPayload = req.body

if (mediaPayload.url) {
await LibraryItemController.prototype.uploadCover.bind(this)(req, res, false)
if (res.writableEnded) return
if (res.writableEnded || res.headersSent) return
}

// Book specific
Expand Down

0 comments on commit f74d741

Please sign in to comment.