From 077343ca205823d13057b3b4b8ef9e653e23f8dd Mon Sep 17 00:00:00 2001 From: sbwalker Date: Wed, 29 Nov 2023 13:58:52 -0500 Subject: [PATCH] suppress logging for resized image files which no longer exist --- Oqtane.Server/Controllers/FileController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Oqtane.Server/Controllers/FileController.cs b/Oqtane.Server/Controllers/FileController.cs index d256c6ad..7c41cf90 100644 --- a/Oqtane.Server/Controllers/FileController.cs +++ b/Oqtane.Server/Controllers/FileController.cs @@ -658,8 +658,15 @@ namespace Oqtane.Controllers } else { - _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Access Attempt {FileId}", id); - HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + if (file != null) + { + _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Access Attempt {FileId}", id); + HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; + } + else + { + HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound; + } } string errorPath = Path.Combine(GetFolderPath("wwwroot/images"), "error.png");