mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Revised Authentication logic for api and logfiles.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user