From 42403ac1c3eccae0df2cca4cbc5ea6f24d92ec45 Mon Sep 17 00:00:00 2001 From: ta264 Date: Wed, 12 May 2021 21:00:23 +0100 Subject: [PATCH] Fixed: Log files should not be cached --- src/Prowlarr.Http/Frontend/Mappers/LogFileMapper.cs | 8 ++++---- .../Frontend/Mappers/UpdateLogFileMapper.cs | 8 ++++---- .../Middleware/CacheableSpecification.cs | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Prowlarr.Http/Frontend/Mappers/LogFileMapper.cs b/src/Prowlarr.Http/Frontend/Mappers/LogFileMapper.cs index c160b72cd..5d4801347 100644 --- a/src/Prowlarr.Http/Frontend/Mappers/LogFileMapper.cs +++ b/src/Prowlarr.Http/Frontend/Mappers/LogFileMapper.cs @@ -6,11 +6,11 @@ using NzbDrone.Common.Extensions; namespace Prowlarr.Http.Frontend.Mappers { - public class UpdateLogFileMapper : StaticResourceMapperBase + public class LogFileMapper : StaticResourceMapperBase { private readonly IAppFolderInfo _appFolderInfo; - public UpdateLogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) : base(diskProvider, logger) { _appFolderInfo = appFolderInfo; @@ -21,12 +21,12 @@ namespace Prowlarr.Http.Frontend.Mappers var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = Path.GetFileName(path); - return Path.Combine(_appFolderInfo.GetUpdateLogFolder(), path); + return Path.Combine(_appFolderInfo.GetLogFolder(), path); } public override bool CanHandle(string resourceUrl) { - return resourceUrl.StartsWith("/updatelogfile/") && resourceUrl.EndsWith(".txt"); + return resourceUrl.StartsWith("/logfile/") && resourceUrl.EndsWith(".txt"); } } } diff --git a/src/Prowlarr.Http/Frontend/Mappers/UpdateLogFileMapper.cs b/src/Prowlarr.Http/Frontend/Mappers/UpdateLogFileMapper.cs index 5d4801347..c160b72cd 100644 --- a/src/Prowlarr.Http/Frontend/Mappers/UpdateLogFileMapper.cs +++ b/src/Prowlarr.Http/Frontend/Mappers/UpdateLogFileMapper.cs @@ -6,11 +6,11 @@ using NzbDrone.Common.Extensions; namespace Prowlarr.Http.Frontend.Mappers { - public class LogFileMapper : StaticResourceMapperBase + public class UpdateLogFileMapper : StaticResourceMapperBase { private readonly IAppFolderInfo _appFolderInfo; - public LogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) + public UpdateLogFileMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, Logger logger) : base(diskProvider, logger) { _appFolderInfo = appFolderInfo; @@ -21,12 +21,12 @@ namespace Prowlarr.Http.Frontend.Mappers var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar); path = Path.GetFileName(path); - return Path.Combine(_appFolderInfo.GetLogFolder(), path); + return Path.Combine(_appFolderInfo.GetUpdateLogFolder(), path); } public override bool CanHandle(string resourceUrl) { - return resourceUrl.StartsWith("/logfile/") && resourceUrl.EndsWith(".txt"); + return resourceUrl.StartsWith("/updatelogfile/") && resourceUrl.EndsWith(".txt"); } } } diff --git a/src/Prowlarr.Http/Middleware/CacheableSpecification.cs b/src/Prowlarr.Http/Middleware/CacheableSpecification.cs index 7b527e507..9a4f9262b 100644 --- a/src/Prowlarr.Http/Middleware/CacheableSpecification.cs +++ b/src/Prowlarr.Http/Middleware/CacheableSpecification.cs @@ -39,23 +39,26 @@ namespace Prowlarr.Http.Middleware return false; } - if (request.Path.Value?.EndsWith("/index.js") ?? false) + var path = request.Path.Value ?? ""; + + if (path.EndsWith("/index.js")) { return false; } - if (request.Path.Value?.EndsWith("/initialize.js") ?? false) + if (path.EndsWith("/initialize.js")) { return false; } - if (request.Path.StartsWithSegments("/feed", StringComparison.CurrentCultureIgnoreCase)) + if (path.StartsWith("/feed", StringComparison.CurrentCultureIgnoreCase)) { return false; } - if (request.Path.StartsWithSegments("/log", StringComparison.CurrentCultureIgnoreCase) && - (request.Path.Value?.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase) ?? false)) + if ((path.StartsWith("/logfile", StringComparison.CurrentCultureIgnoreCase) || + path.StartsWith("/updatelogfile", StringComparison.CurrentCultureIgnoreCase)) && + path.EndsWith(".txt", StringComparison.CurrentCultureIgnoreCase)) { return false; }