1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs

31 lines
903 B
C#
Raw Normal View History

2013-07-29 02:13:14 +03:00
using System.IO;
using NLog;
2013-07-29 02:13:14 +03:00
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Api.Frontend.Mappers
2013-07-29 02:13:14 +03:00
{
public class LogFileMapper : StaticResourceMapperBase
2013-07-29 02:13:14 +03:00
{
private readonly IAppFolderInfo _appFolderInfo;
public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
: base(diskProvider, logger)
2013-07-29 02:13:14 +03:00
{
_appFolderInfo = appFolderInfo;
}
protected override string Map(string resourceUrl)
2013-07-29 02:13:14 +03:00
{
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
path = Path.GetFileName(path);
return Path.Combine(_appFolderInfo.GetLogFolder(), path);
}
public override bool CanHandle(string resourceUrl)
2013-07-29 02:13:14 +03:00
{
return resourceUrl.StartsWith("/log") && resourceUrl.EndsWith(".txt");
2013-07-29 02:13:14 +03:00
}
}
}