suppress logging for resized image files which no longer exist

This commit is contained in:
sbwalker 2023-11-29 13:58:52 -05:00
parent 2344a49260
commit 077343ca20

View File

@ -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");