2013-07-29 02:13:14 +03:00
|
|
|
using System.IO;
|
2013-08-20 09:23:36 +03:00
|
|
|
using NLog;
|
2013-07-29 02:13:14 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
2013-08-20 05:31:26 +03:00
|
|
|
namespace NzbDrone.Api.Frontend.Mappers
|
2013-07-29 02:13:14 +03:00
|
|
|
{
|
2013-08-20 09:23:36 +03:00
|
|
|
public class LogFileMapper : StaticResourceMapperBase
|
2013-07-29 02:13:14 +03:00
|
|
|
{
|
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
|
|
|
|
2013-08-20 09:23:36 +03:00
|
|
|
public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger)
|
|
|
|
: base(diskProvider, logger)
|
2013-07-29 02:13:14 +03:00
|
|
|
{
|
|
|
|
_appFolderInfo = appFolderInfo;
|
|
|
|
}
|
|
|
|
|
2013-08-20 09:23:36 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-08-20 09:23:36 +03:00
|
|
|
public override bool CanHandle(string resourceUrl)
|
2013-07-29 02:13:14 +03:00
|
|
|
{
|
2013-08-03 08:07:32 +03:00
|
|
|
return resourceUrl.StartsWith("/log") && resourceUrl.EndsWith(".txt");
|
2013-07-29 02:13:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|