From 9f0ae763fffa0c309d72dc78e4ff77be2b7388e0 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 19 Aug 2013 23:23:36 -0700 Subject: [PATCH] moved logic for reading static file to mappers --- NzbDrone.Api/Frontend/IAddCacheHeaders.cs | 32 -------- .../Mappers/IMapHttpRequestsToDisk.cs | 4 +- .../Frontend/Mappers/IndexHtmlMapper.cs | 30 ++++++- .../Frontend/Mappers/LogFileMapper.cs | 10 ++- .../Frontend/Mappers/MediaCoverMapper.cs | 10 ++- .../Frontend/Mappers/StaticResourceMapper.cs | 11 ++- .../Mappers/StaticResourceMapperBase.cs | 66 ++++++++++++++++ NzbDrone.Api/Frontend/StaticResourceModule.cs | 59 +------------- .../Frontend/StaticResourceProvider.cs | 79 ------------------- NzbDrone.Api/NzbDrone.Api.csproj | 3 +- .../MessageAggregatorCommandTests.cs | 2 + NzbDrone.Common/HttpProvider.cs | 21 ++--- NzbDrone.Core.Test/Framework/CoreTest.cs | 4 +- .../CoverExistsSpecificationFixture.cs | 4 +- .../NotificationServiceFixture.cs | 4 +- .../Scene/SceneMappingService.cs | 4 +- .../IndexerSearch/NzbSearchService.cs | 2 +- .../CoverAlreadyExistsSpecification.cs | 2 +- NzbDrone.Core/Notifications/Xbmc/Xbmc.cs | 5 +- NzbDrone.sln.DotSettings | 1 + 20 files changed, 144 insertions(+), 209 deletions(-) delete mode 100644 NzbDrone.Api/Frontend/IAddCacheHeaders.cs create mode 100644 NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs delete mode 100644 NzbDrone.Api/Frontend/StaticResourceProvider.cs diff --git a/NzbDrone.Api/Frontend/IAddCacheHeaders.cs b/NzbDrone.Api/Frontend/IAddCacheHeaders.cs deleted file mode 100644 index d1a734fb1..000000000 --- a/NzbDrone.Api/Frontend/IAddCacheHeaders.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using Nancy; -using NzbDrone.Api.Extensions; -using NzbDrone.Common.EnvironmentInfo; - -namespace NzbDrone.Api.Frontend -{ - public interface IAddCacheHeaders - { - void ToResponse(Request request, Response response); - } - - public class AddCacheHeaders : IAddCacheHeaders - { - public void ToResponse(Request request, Response response) - { - if (!RuntimeInfo.IsProduction) - { - response.Headers.DisableCache(); - return; - } - - if (request.Url.Path.EndsWith("app.js", StringComparison.CurrentCultureIgnoreCase)) - { - response.Headers.DisableCache(); - return; - } - - response.Headers.EnableCache(); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Api/Frontend/Mappers/IMapHttpRequestsToDisk.cs b/NzbDrone.Api/Frontend/Mappers/IMapHttpRequestsToDisk.cs index f57530643..20216f49c 100644 --- a/NzbDrone.Api/Frontend/Mappers/IMapHttpRequestsToDisk.cs +++ b/NzbDrone.Api/Frontend/Mappers/IMapHttpRequestsToDisk.cs @@ -1,9 +1,11 @@  +using Nancy; + namespace NzbDrone.Api.Frontend.Mappers { public interface IMapHttpRequestsToDisk { - string Map(string resourceUrl); bool CanHandle(string resourceUrl); + Response GetResponse(string resourceUrl); } } diff --git a/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs b/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs index c90531ee9..fb11b68aa 100644 --- a/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs +++ b/NzbDrone.Api/Frontend/Mappers/IndexHtmlMapper.cs @@ -1,25 +1,47 @@ using System.IO; +using NLog; +using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Api.Frontend.Mappers { - public class IndexHtmlMapper : IMapHttpRequestsToDisk + public class IndexHtmlMapper : StaticResourceMapperBase { + private readonly IDiskProvider _diskProvider; private readonly string _indexPath; - public IndexHtmlMapper(IAppFolderInfo appFolderInfo) + public IndexHtmlMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + : base(diskProvider, logger) { + _diskProvider = diskProvider; _indexPath = Path.Combine(appFolderInfo.StartUpFolder, "UI", "index.html"); } - public string Map(string resourceUrl) + protected override string Map(string resourceUrl) { return _indexPath; } - public bool CanHandle(string resourceUrl) + public override bool CanHandle(string resourceUrl) { return !resourceUrl.Contains("."); } + + protected override Stream GetContentStream(string filePath) + { + return StringToStream(GetIndexText()); + } + + + private string GetIndexText() + { + var text = _diskProvider.ReadAllText(_indexPath); + + text = text.Replace(".css", ".css?v=" + BuildInfo.Version); + text = text.Replace(".js", ".js?v=" + BuildInfo.Version); + + return text; + } + } } \ No newline at end of file diff --git a/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs b/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs index 36cfc18bf..e41a9b711 100644 --- a/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs +++ b/NzbDrone.Api/Frontend/Mappers/LogFileMapper.cs @@ -1,19 +1,21 @@ using System.IO; +using NLog; using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Api.Frontend.Mappers { - public class LogFileMapper : IMapHttpRequestsToDisk + public class LogFileMapper : StaticResourceMapperBase { private readonly IAppFolderInfo _appFolderInfo; - public LogFileMapper(IAppFolderInfo appFolderInfo) + public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + : base(diskProvider, logger) { _appFolderInfo = appFolderInfo; } - public string Map(string resourceUrl) + protected override string Map(string resourceUrl) { var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = Path.GetFileName(path); @@ -21,7 +23,7 @@ namespace NzbDrone.Api.Frontend.Mappers return Path.Combine(_appFolderInfo.GetLogFolder(), path); } - public bool CanHandle(string resourceUrl) + public override bool CanHandle(string resourceUrl) { return resourceUrl.StartsWith("/log") && resourceUrl.EndsWith(".txt"); } diff --git a/NzbDrone.Api/Frontend/Mappers/MediaCoverMapper.cs b/NzbDrone.Api/Frontend/Mappers/MediaCoverMapper.cs index 7400614cf..3fe35324b 100644 --- a/NzbDrone.Api/Frontend/Mappers/MediaCoverMapper.cs +++ b/NzbDrone.Api/Frontend/Mappers/MediaCoverMapper.cs @@ -1,19 +1,21 @@ using System.IO; +using NLog; using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Api.Frontend.Mappers { - public class MediaCoverMapper : IMapHttpRequestsToDisk + public class MediaCoverMapper : StaticResourceMapperBase { private readonly IAppFolderInfo _appFolderInfo; - public MediaCoverMapper(IAppFolderInfo appFolderInfo) + public MediaCoverMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + : base(diskProvider, logger) { _appFolderInfo = appFolderInfo; } - public string Map(string resourceUrl) + protected override string Map(string resourceUrl) { var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = path.Trim(Path.DirectorySeparatorChar); @@ -21,7 +23,7 @@ namespace NzbDrone.Api.Frontend.Mappers return Path.Combine(_appFolderInfo.GetAppDataPath(), path); } - public bool CanHandle(string resourceUrl) + public override bool CanHandle(string resourceUrl) { return resourceUrl.StartsWith("/MediaCover"); } diff --git a/NzbDrone.Api/Frontend/Mappers/StaticResourceMapper.cs b/NzbDrone.Api/Frontend/Mappers/StaticResourceMapper.cs index cd1f619e8..b97f63943 100644 --- a/NzbDrone.Api/Frontend/Mappers/StaticResourceMapper.cs +++ b/NzbDrone.Api/Frontend/Mappers/StaticResourceMapper.cs @@ -1,18 +1,21 @@ using System.IO; +using NLog; +using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Api.Frontend.Mappers { - public class StaticResourceMapper : IMapHttpRequestsToDisk + public class StaticResourceMapper : StaticResourceMapperBase { private readonly IAppFolderInfo _appFolderInfo; - public StaticResourceMapper(IAppFolderInfo appFolderInfo) + public StaticResourceMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + : base(diskProvider, logger) { _appFolderInfo = appFolderInfo; } - public string Map(string resourceUrl) + protected override string Map(string resourceUrl) { var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = path.Trim(Path.DirectorySeparatorChar); @@ -20,7 +23,7 @@ namespace NzbDrone.Api.Frontend.Mappers return Path.Combine(_appFolderInfo.StartUpFolder, "UI", path); } - public bool CanHandle(string resourceUrl) + public override bool CanHandle(string resourceUrl) { return resourceUrl.StartsWith("/Content") || resourceUrl.EndsWith(".js") || resourceUrl.EndsWith(".css"); } diff --git a/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs b/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs new file mode 100644 index 000000000..e789c01a7 --- /dev/null +++ b/NzbDrone.Api/Frontend/Mappers/StaticResourceMapperBase.cs @@ -0,0 +1,66 @@ +using System.IO; +using NLog; +using Nancy; +using Nancy.Responses; +using NzbDrone.Common; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Api.Frontend.Mappers +{ + public abstract class StaticResourceMapperBase : IMapHttpRequestsToDisk + { + private readonly IDiskProvider _diskProvider; + private readonly Logger _logger; + private readonly bool _caseSensitive; + + private static readonly NotFoundResponse NotFoundResponse = new NotFoundResponse(); + + protected StaticResourceMapperBase(IDiskProvider diskProvider, Logger logger) + { + _diskProvider = diskProvider; + _logger = logger; + + if (!RuntimeInfo.IsProduction) + { + _caseSensitive = true; + } + + + } + + protected abstract string Map(string resourceUrl); + + + public abstract bool CanHandle(string resourceUrl); + + public Response GetResponse(string resourceUrl) + { + var filePath = Map(resourceUrl); + + if (_diskProvider.FileExists(filePath, _caseSensitive)) + { + var response = new StreamResponse(() => GetContentStream(filePath), MimeTypes.GetMimeType(filePath)); + return response; + } + + _logger.Warn("File {0} not found", filePath); + + return NotFoundResponse; + } + + protected virtual Stream GetContentStream(string filePath) + { + return File.OpenRead(filePath); + } + + protected static Stream StringToStream(string text) + { + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(text); + writer.Flush(); + stream.Position = 0; + return stream; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Api/Frontend/StaticResourceModule.cs b/NzbDrone.Api/Frontend/StaticResourceModule.cs index 5a160fe3b..a988ce3de 100644 --- a/NzbDrone.Api/Frontend/StaticResourceModule.cs +++ b/NzbDrone.Api/Frontend/StaticResourceModule.cs @@ -1,41 +1,25 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using NLog; using Nancy; -using Nancy.Responses; using NzbDrone.Api.Frontend.Mappers; -using NzbDrone.Common; -using NzbDrone.Common.Cache; -using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Api.Frontend { public class StaticResourceModule : NancyModule { - private readonly IDiskProvider _diskProvider; private readonly IEnumerable _requestMappers; private readonly Logger _logger; - private readonly ICached _indexCache; - private readonly bool _caseSensitive; - public StaticResourceModule(IDiskProvider diskProvider, ICacheManger cacheManger, IEnumerable requestMappers, Logger logger) + public StaticResourceModule(IEnumerable requestMappers, Logger logger) { - _diskProvider = diskProvider; _requestMappers = requestMappers; _logger = logger; - _indexCache = cacheManger.GetCache(typeof(StaticResourceModule)); - Get["/{resource*}"] = x => Index(); Get["/"] = x => Index(); - - if (!RuntimeInfo.IsProduction) - { - _caseSensitive = true; - } } private Response Index() @@ -50,52 +34,17 @@ namespace NzbDrone.Api.Frontend return null; } - var mapper = _requestMappers.SingleOrDefault(m => m.CanHandle(path)); if (mapper != null) { - var filePath = mapper.Map(path); - - if (_diskProvider.FileExists(filePath, _caseSensitive)) - { - var response = new StreamResponse(() => File.OpenRead(filePath), MimeTypes.GetMimeType(filePath)); - return response; - } - - _logger.Warn("File {0} not found", filePath); - } - else - { - _logger.Warn("Couldn't find handler for {0}", path); + return mapper.GetResponse(path); } - return new NotFoundResponse(); - - /* htmlResponse.Contents = stream => - { - var lastWrite = _diskProvider.GetLastFileWrite(_indexPath); - var text = _indexCache.Get(lastWrite.Ticks.ToString(), GetIndexText); - - var streamWriter = new StreamWriter(stream); - - streamWriter.Write(text); - streamWriter.Flush(); - };*/ + _logger.Warn("Couldn't find handler for {0}", path); - //htmlResponse.Headers.DisableCache(); + return null; } - - - /* private string GetIndexText() - { - var text = _diskProvider.ReadAllText(_indexPath); - - text = text.Replace(".css", ".css?v=" + BuildInfo.Version); - text = text.Replace(".js", ".js?v=" + BuildInfo.Version); - - return text; - }*/ } } \ No newline at end of file diff --git a/NzbDrone.Api/Frontend/StaticResourceProvider.cs b/NzbDrone.Api/Frontend/StaticResourceProvider.cs deleted file mode 100644 index 7a757a155..000000000 --- a/NzbDrone.Api/Frontend/StaticResourceProvider.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NLog; -using Nancy; -using Nancy.Responses; -using NzbDrone.Api.Frontend.Mappers; -using NzbDrone.Common; -using NzbDrone.Common.EnvironmentInfo; - -namespace NzbDrone.Api.Frontend -{ - public interface IProcessStaticResource - { - Response ProcessStaticResourceRequest(NancyContext context, string workingFolder); - } - - public class StaticResourceProvider : IProcessStaticResource - { - private readonly IDiskProvider _diskProvider; - private readonly IEnumerable _requestMappers; - private readonly IAddCacheHeaders _addCacheHeaders; - private readonly Logger _logger; - - private readonly bool _caseSensitive; - - public StaticResourceProvider(IDiskProvider diskProvider, - IEnumerable requestMappers, - IAddCacheHeaders addCacheHeaders, - Logger logger) - { - _diskProvider = diskProvider; - _requestMappers = requestMappers; - _addCacheHeaders = addCacheHeaders; - _logger = logger; - - if (!RuntimeInfo.IsProduction) - { - _caseSensitive = true; - } - } - - public Response ProcessStaticResourceRequest(NancyContext context, string workingFolder) - { - var path = context.Request.Url.Path; - - if (string.IsNullOrWhiteSpace(path)) - { - return null; - } - - if (context.Request.Headers.IfModifiedSince.HasValue) - { - var response = new Response { ContentType = MimeTypes.GetMimeType(path), StatusCode = HttpStatusCode.NotModified }; - _addCacheHeaders.ToResponse(context.Request, response); - return response; - } - - var mapper = _requestMappers.SingleOrDefault(m => m.CanHandle(path)); - - if (mapper != null) - { - var filePath = mapper.Map(path); - - if (_diskProvider.FileExists(filePath, _caseSensitive)) - { - var response = new StreamResponse(() => File.OpenRead(filePath), MimeTypes.GetMimeType(filePath)); - _addCacheHeaders.ToResponse(context.Request, response); - - return response; - } - - _logger.Warn("File {0} not found", filePath); - } - - return null; - } - } -} \ No newline at end of file diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index cc87521aa..260c075a2 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -96,15 +96,14 @@ - + - diff --git a/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs b/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs index d0bbae9a5..1e450ae21 100644 --- a/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs +++ b/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs @@ -76,7 +76,9 @@ namespace NzbDrone.Common.Test.EventingTests public class CommandA : ICommand { +// ReSharper disable UnusedParameter.Local public CommandA(int id = 0) +// ReSharper restore UnusedParameter.Local { } diff --git a/NzbDrone.Common/HttpProvider.cs b/NzbDrone.Common/HttpProvider.cs index 4e3ea8817..1e818c3eb 100644 --- a/NzbDrone.Common/HttpProvider.cs +++ b/NzbDrone.Common/HttpProvider.cs @@ -22,14 +22,15 @@ namespace NzbDrone.Common public class HttpProvider : IHttpProvider { + private readonly Logger _logger; - public const string ContentLenghtHeader = "Content-Length"; + public const string CONTENT_LENGHT_HEADER = "Content-Length"; - private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private readonly string _userAgent; - public HttpProvider() + public HttpProvider(Logger logger) { + _logger = logger; _userAgent = String.Format("NzbDrone {0}", BuildInfo.Version); } @@ -53,12 +54,12 @@ namespace NzbDrone.Common } catch (WebException e) { - logger.Warn("Failed to get response from: {0} {1}", url, e.Message); + _logger.Warn("Failed to get response from: {0} {1}", url, e.Message); throw; } catch (Exception e) { - logger.WarnException("Failed to get response from: " + url, e); + _logger.WarnException("Failed to get response from: " + url, e); throw; } } @@ -101,23 +102,23 @@ namespace NzbDrone.Common fileInfo.Directory.Create(); } - logger.Trace("Downloading [{0}] to [{1}]", url, fileName); + _logger.Trace("Downloading [{0}] to [{1}]", url, fileName); var stopWatch = Stopwatch.StartNew(); var webClient = new WebClient(); webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); webClient.DownloadFile(url, fileName); stopWatch.Stop(); - logger.Trace("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); + _logger.Trace("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds); } catch (WebException e) { - logger.Warn("Failed to get response from: {0} {1}", url, e.Message); + _logger.Warn("Failed to get response from: {0} {1}", url, e.Message); throw; } catch (Exception e) { - logger.WarnException("Failed to get response from: " + url, e); + _logger.WarnException("Failed to get response from: " + url, e); throw; } } @@ -126,7 +127,7 @@ namespace NzbDrone.Common { address = String.Format("http://{0}/jsonrpc", address); - logger.Trace("Posting command: {0}, to {1}", command, address); + _logger.Trace("Posting command: {0}, to {1}", command, address); byte[] byteArray = Encoding.ASCII.GetBytes(command); diff --git a/NzbDrone.Core.Test/Framework/CoreTest.cs b/NzbDrone.Core.Test/Framework/CoreTest.cs index d2cc9ff7e..933fa4c5e 100644 --- a/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -7,8 +7,6 @@ namespace NzbDrone.Core.Test.Framework { public abstract class CoreTest : TestBase { - - protected FileStream OpenRead(params string[] path) { return File.OpenRead(Path.Combine(path)); @@ -21,7 +19,7 @@ namespace NzbDrone.Core.Test.Framework protected void UseRealHttp() { - Mocker.SetConstant(new HttpProvider()); + Mocker.SetConstant(new HttpProvider(TestLogger)); } protected void UseRealDisk() diff --git a/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs b/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs index 0c87594df..e2a5b68f4 100644 --- a/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaCoverTests/CoverExistsSpecificationFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests public void should_return_false_if_file_exists_but_diffrent_size() { GivenExistingFileSize(100); - _headers.Add(HttpProvider.ContentLenghtHeader, "200"); + _headers.Add(HttpProvider.CONTENT_LENGHT_HEADER, "200"); Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeFalse(); } @@ -58,7 +58,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests public void should_return_ture_if_file_exists_and_same_size() { GivenExistingFileSize(100); - _headers.Add(HttpProvider.ContentLenghtHeader, "100"); + _headers.Add(HttpProvider.CONTENT_LENGHT_HEADER, "100"); Subject.AlreadyExists("http://url", "c:\\file.exe").Should().BeTrue(); } diff --git a/NzbDrone.Core.Test/NotificationTests/NotificationServiceFixture.cs b/NzbDrone.Core.Test/NotificationTests/NotificationServiceFixture.cs index 3569f2766..80875d24f 100644 --- a/NzbDrone.Core.Test/NotificationTests/NotificationServiceFixture.cs +++ b/NzbDrone.Core.Test/NotificationTests/NotificationServiceFixture.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.NotificationTests { _notifications = new List(); - _notifications.Add(new Notifications.Xbmc.Xbmc(null, null)); + _notifications.Add(new Notifications.Xbmc.Xbmc(null)); _notifications.Add(new PlexClient(null)); _notifications.Add(new PlexServer(null)); _notifications.Add(new Email(null)); @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.NotificationTests Mocker.SetConstant(Mocker.Resolve()); Mocker.GetMock().Setup(s => s.Resolve(typeof(Notifications.Xbmc.Xbmc))) - .Returns(new Notifications.Xbmc.Xbmc(null, null)); + .Returns(new Notifications.Xbmc.Xbmc(null)); Mocker.GetMock().Setup(s => s.Resolve(typeof(PlexClient))) .Returns(new PlexClient(null)); diff --git a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs index 962b861c9..3c84d378c 100644 --- a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene { public interface ISceneMappingService { - string GetSceneName(int tvdbId, int seasonNumber = -1); + string GetSceneName(int tvdbId); Nullable GetTvDbId(string cleanName); } @@ -35,7 +35,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene _logger = logger; } - public string GetSceneName(int tvdbId, int seasonNumber = -1) + public string GetSceneName(int tvdbId) { var mapping = _getSceneNameCache.Find(tvdbId.ToString()); diff --git a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index fcf15463b..7386341d2 100644 --- a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -116,7 +116,7 @@ namespace NzbDrone.Core.IndexerSearch spec.SeriesId = series.Id; spec.SeriesTvRageId = series.TvRageId; - spec.SceneTitle = _sceneMapping.GetSceneName(series.TvdbId, seasonNumber); + spec.SceneTitle = _sceneMapping.GetSceneName(series.TvdbId); if (string.IsNullOrWhiteSpace(spec.SceneTitle)) { diff --git a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs index fd4bcff52..e81ce068f 100644 --- a/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs +++ b/NzbDrone.Core/MediaCover/CoverAlreadyExistsSpecification.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaCover string sizeString; - if (headers.TryGetValue(HttpProvider.ContentLenghtHeader, out sizeString)) + if (headers.TryGetValue(HttpProvider.CONTENT_LENGHT_HEADER, out sizeString)) { int size; int.TryParse(sizeString, out size); diff --git a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index 20cfc80fe..f42228ee6 100644 --- a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -1,5 +1,4 @@ -using NLog; -using NzbDrone.Core.Tv; +using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Xbmc { @@ -7,7 +6,7 @@ namespace NzbDrone.Core.Notifications.Xbmc { private readonly IXbmcService _xbmcProvider; - public Xbmc(IXbmcService xbmcProvider, Logger logger) + public Xbmc(IXbmcService xbmcProvider) { _xbmcProvider = xbmcProvider; } diff --git a/NzbDrone.sln.DotSettings b/NzbDrone.sln.DotSettings index 86121dceb..2aded5528 100644 --- a/NzbDrone.sln.DotSettings +++ b/NzbDrone.sln.DotSettings @@ -9,6 +9,7 @@ ERROR HINT WARNING + WARNING HINT <?xml version="1.0" encoding="utf-16"?><Profile name="NzbDrone"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>IMPLICIT_EXCEPT_SIMPLE_TYPES</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSUpdateFileHeader>True</CSUpdateFileHeader><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReorderTypeMembers>True</CSReorderTypeMembers><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile> NzbDrone