mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-10 23:33:38 -07:00
Revised Authentication logic for api and logfiles.
This commit is contained in:
parent
9645fb07db
commit
f92aded4f0
4 changed files with 23 additions and 24 deletions
|
@ -4,11 +4,15 @@ using System.Linq;
|
|||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
|
||||
namespace NzbDrone.Api.Logs
|
||||
{
|
||||
public class LogFileModule : NzbDroneRestModule<LogFileResource>
|
||||
{
|
||||
private const string LOGFILE_ROUTE = @"/(?<filename>nzbdrone(?:\.\d+)?\.txt)";
|
||||
|
||||
private readonly IAppFolderInfo _appFolderInfo;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
|
||||
|
@ -19,6 +23,8 @@ namespace NzbDrone.Api.Logs
|
|||
_appFolderInfo = appFolderInfo;
|
||||
_diskProvider = diskProvider;
|
||||
GetResourceAll = GetLogFiles;
|
||||
|
||||
Get[LOGFILE_ROUTE] = options => GetLogFile(options.filename);
|
||||
}
|
||||
|
||||
private List<LogFileResource> GetLogFiles()
|
||||
|
@ -41,5 +47,17 @@ namespace NzbDrone.Api.Logs
|
|||
|
||||
return result.OrderByDescending(l => l.LastWriteTime).ToList();
|
||||
}
|
||||
|
||||
private Response GetLogFile(string filename)
|
||||
{
|
||||
var filePath = Path.Combine(_appFolderInfo.GetLogFolder(), filename);
|
||||
|
||||
if (!_diskProvider.FileExists(filePath))
|
||||
return new NotFoundResponse();
|
||||
|
||||
var data = _diskProvider.ReadAllText(filePath);
|
||||
|
||||
return new TextResponse(data);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue