mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Return 404 if log file does not exist
This commit is contained in:
parent
a32fe89dad
commit
918b627472
1 changed files with 10 additions and 2 deletions
|
@ -188,16 +188,24 @@ public class SystemController : BaseJellyfinApiController
|
||||||
/// <param name="name">The name of the log file to get.</param>
|
/// <param name="name">The name of the log file to get.</param>
|
||||||
/// <response code="200">Log file retrieved.</response>
|
/// <response code="200">Log file retrieved.</response>
|
||||||
/// <response code="403">User does not have permission to get log files.</response>
|
/// <response code="403">User does not have permission to get log files.</response>
|
||||||
|
/// <response code="404">Could not find a log file with the name.</response>
|
||||||
/// <returns>The log file.</returns>
|
/// <returns>The log file.</returns>
|
||||||
[HttpGet("Logs/Log")]
|
[HttpGet("Logs/Log")]
|
||||||
[Authorize(Policy = Policies.RequiresElevation)]
|
[Authorize(Policy = Policies.RequiresElevation)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[ProducesFile(MediaTypeNames.Text.Plain)]
|
[ProducesFile(MediaTypeNames.Text.Plain)]
|
||||||
public ActionResult GetLogFile([FromQuery, Required] string name)
|
public ActionResult GetLogFile([FromQuery, Required] string name)
|
||||||
{
|
{
|
||||||
var file = _fileSystem.GetFiles(_appPaths.LogDirectoryPath)
|
var file = _fileSystem
|
||||||
.First(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
.GetFiles(_appPaths.LogDirectoryPath)
|
||||||
|
.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (file is null)
|
||||||
|
{
|
||||||
|
return NotFound("Log file not found.");
|
||||||
|
}
|
||||||
|
|
||||||
// For older files, assume fully static
|
// For older files, assume fully static
|
||||||
var fileShare = file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1) ? FileShare.Read : FileShare.ReadWrite;
|
var fileShare = file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1) ? FileShare.Read : FileShare.ReadWrite;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue