From 20a365706313b2fe9f3e5f73bfef83a1deba135c Mon Sep 17 00:00:00 2001 From: mikiher Date: Tue, 20 Aug 2024 10:51:24 +0300 Subject: [PATCH] Update AuthorController to handle invalid image paths and log a warning --- server/controllers/AuthorController.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/controllers/AuthorController.js b/server/controllers/AuthorController.js index 22b11b3c3e..99b977637b 100644 --- a/server/controllers/AuthorController.js +++ b/server/controllers/AuthorController.js @@ -368,12 +368,12 @@ class AuthorController { author } = req - if (raw) { - // any value - if (!author.imagePath || !(await fs.pathExists(author.imagePath))) { - return res.sendStatus(404) - } + if (!author.imagePath || !(await fs.pathExists(author.imagePath))) { + Logger.warn(`[AuthorController] Author "${author.name}" has invalid imagePath: ${author.imagePath}`) + return res.sendStatus(404) + } + if (raw) { return res.sendFile(author.imagePath) }