Update AuthorController to handle invalid image paths and log a warning

This commit is contained in:
mikiher 2024-08-20 10:51:24 +03:00
parent 26d2c5a8f0
commit 20a3657063

View File

@ -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)
}