From f74d741821c7c4cfc5dd9ae9fe605d163153a8e9 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 20 Apr 2024 11:34:21 -0500 Subject: [PATCH] Fix:Server crash when updating media with external cover url that fails to download #2857 --- server/controllers/LibraryItemController.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 3fa7743a3b..e987dda057 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -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