From aca8b82ae66ade8d07a29926b241298eca197a2c Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 8 Oct 2023 22:58:42 +0300 Subject: [PATCH] Fixed: Avoid logging evaluations when not using any Remote Path Mappings (cherry picked from commit 44eb729ccc13237f4439006159bd616e8bdb5750) --- .../RemotePathMappingService.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs b/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs index 5e033b582..b757db3f3 100644 --- a/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs +++ b/src/NzbDrone.Core/RemotePathMappings/RemotePathMappingService.cs @@ -127,8 +127,16 @@ namespace NzbDrone.Core.RemotePathMappings return remotePath; } + var mappings = All(); + + if (mappings.Empty()) + { + return remotePath; + } + _logger.Trace("Evaluating remote path remote mappings for match to host [{0}] and remote path [{1}]", host, remotePath.FullPath); - foreach (var mapping in All()) + + foreach (var mapping in mappings) { _logger.Trace("Checking configured remote path mapping: {0} - {1}", mapping.Host, mapping.RemotePath); if (host.Equals(mapping.Host, StringComparison.InvariantCultureIgnoreCase) && new OsPath(mapping.RemotePath).Contains(remotePath)) @@ -150,8 +158,16 @@ namespace NzbDrone.Core.RemotePathMappings return localPath; } + var mappings = All(); + + if (mappings.Empty()) + { + return localPath; + } + _logger.Trace("Evaluating remote path local mappings for match to host [{0}] and local path [{1}]", host, localPath.FullPath); - foreach (var mapping in All()) + + foreach (var mapping in mappings) { _logger.Trace("Checking configured remote path mapping {0} - {1}", mapping.Host, mapping.RemotePath); if (host.Equals(mapping.Host, StringComparison.InvariantCultureIgnoreCase) && new OsPath(mapping.LocalPath).Contains(localPath))