From ebba206c1b2bb9d64bf867f158011dc2d789be71 Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Wed, 21 Jan 2026 14:25:50 -0500 Subject: [PATCH] Remove redundant comments from Listenarr codebase Cleaned up unnecessary and explanatory comments in Listenarr-related classes and tests to improve code readability and maintain consistency. No functional changes were made. --- .../Listenarr/ListenarrFixture.cs | 2 -- .../Applications/Listenarr/Listenarr.cs | 20 +------------------ .../Listenarr/ListenarrV1Proxy.cs | 2 -- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/NzbDrone.Core.Test/Applications/Listenarr/ListenarrFixture.cs b/src/NzbDrone.Core.Test/Applications/Listenarr/ListenarrFixture.cs index 3dba5e6bb..84f1fc873 100644 --- a/src/NzbDrone.Core.Test/Applications/Listenarr/ListenarrFixture.cs +++ b/src/NzbDrone.Core.Test/Applications/Listenarr/ListenarrFixture.cs @@ -35,8 +35,6 @@ public void Setup() Mocker.GetMock().SetupGet(c => c.ApiKey).Returns("abc"); - // Ensure cache calls execute factory each time during tests to avoid stale cached values - // Use ICached> mock via dynamic mocking to avoid depending on concrete implementation var cached = new Mock>>(); cached.Setup(c => c.Get(It.IsAny(), It.IsAny>>(), It.IsAny())) .Returns>, TimeSpan>((k, f, t) => f()); diff --git a/src/NzbDrone.Core/Applications/Listenarr/Listenarr.cs b/src/NzbDrone.Core/Applications/Listenarr/Listenarr.cs index cdbea5740..eaea83e67 100644 --- a/src/NzbDrone.Core/Applications/Listenarr/Listenarr.cs +++ b/src/NzbDrone.Core/Applications/Listenarr/Listenarr.cs @@ -47,9 +47,6 @@ public override ValidationResult Test() testIndexer.Capabilities.Categories.AddCategoryMapping(1, cat); } - // Call the application's TestConnection directly, consistent with other application implementations. - // Some applications do not expose a reliable system status endpoint, so we rely on the indexer test itself - // to provide actionable feedback (auth, version, connectivity etc.). try { failures.AddIfNotNull(_listenarrV1Proxy.TestConnection(BuildListenarrIndexer(testIndexer, testIndexer.Capabilities, DownloadProtocol.Usenet), Settings)); @@ -112,7 +109,6 @@ public override List GetIndexerMappings() if (match.Groups["indexer"].Success && int.TryParse(match.Groups["indexer"].Value, out var indexerId)) { - // Add parsed mapping if it's mapped to a Indexer in this Prowlarr instance mappings.Add(new AppIndexerMap { IndexerId = indexerId, RemoteIndexerId = indexer.Id }); } } @@ -142,7 +138,6 @@ public override void AddIndexer(IndexerDefinition indexer) var listenarrIndexer = BuildListenarrIndexer(indexer, indexerCapabilities, indexer.Protocol); - // If an existing remote indexer already points to this app indexer (matching baseUrl or name), insert mapping and skip adding try { var remoteIndexers = _listenarrV1Proxy.GetIndexers(Settings); @@ -198,7 +193,6 @@ public override void UpdateIndexer(IndexerDefinition indexer, bool forceSync = f var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexer.Id); - // If there is no mapping, treat this as an add instead of an update if (indexerMapping == null) { if ((indexerCapabilities.MusicSearchAvailable || indexerCapabilities.SearchAvailable) && @@ -225,7 +219,6 @@ public override void UpdateIndexer(IndexerDefinition indexer, bool forceSync = f } else { - // If add returned null or failed, try to discover existing remote indexer by baseUrl or name try { var remoteIndexers = _listenarrV1Proxy.GetIndexers(Settings); @@ -259,7 +252,6 @@ public override void UpdateIndexer(IndexerDefinition indexer, bool forceSync = f return; } - // If mapping exists but contains an invalid remote id (0), remove and re-add if possible if (indexerMapping.RemoteIndexerId == 0) { _logger.Warn("Mapping for indexer {0} contains invalid remote id 0, removing mapping and re-adding if possible", indexer.Id); @@ -335,30 +327,25 @@ public override void UpdateIndexer(IndexerDefinition indexer, bool forceSync = f if ((indexerCapabilities.MusicSearchAvailable || indexerCapabilities.SearchAvailable) && indexerCapabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()).Any()) { - // Retain user fields not-affiliated with Prowlarr + if (remoteIndexer.Fields != null) { listenarrIndexer.Fields.AddRange(remoteIndexer.Fields.Where(f => listenarrIndexer.Fields.All(s => s.Name != f.Name))); } - // Retain user tags not-affiliated with Prowlarr if (remoteIndexer.Tags != null) { listenarrIndexer.Tags.UnionWith(remoteIndexer.Tags); } - // Retain user settings not-affiliated with Prowlarr listenarrIndexer.DownloadClientId = remoteIndexer.DownloadClientId; - // Ensure ID is in sync with remote before updating listenarrIndexer.Id = remoteIndexer.Id; - // Update the indexer if it still has categories that match _listenarrV1Proxy.UpdateIndexer(listenarrIndexer, Settings); } else { - // Else remove it, it no longer should be used _listenarrV1Proxy.RemoveIndexer(remoteIndexer.Id, Settings); _appIndexerMapService.Delete(indexerMapping.Id); } @@ -389,10 +376,8 @@ private ListenarrIndexer BuildListenarrIndexer(IndexerDefinition indexer, Indexe var schemas = _schemaCache.Get(cacheKey, () => _listenarrV1Proxy.GetIndexerSchema(Settings), TimeSpan.FromDays(7)); var syncFields = new List { "baseUrl", "apiPath", "apiKey", "categories", "minimumSeeders", "seedCriteria.seedRatio", "seedCriteria.seedTime", "seedCriteria.discographySeedTime", "rejectBlocklistedTorrentHashesWhileGrabbing" }; - // Validate schema presence and contents. Listenarr can sometimes return no schema or an unexpected shape if (schemas == null || !schemas.Any()) { - // Try refreshing schemas directly from proxy in case the cache is empty or stale try { schemas = _listenarrV1Proxy.GetIndexerSchema(Settings); @@ -412,7 +397,6 @@ private ListenarrIndexer BuildListenarrIndexer(IndexerDefinition indexer, Indexe if (id == 0) { - // Ensuring backward compatibility with older versions on first sync syncFields.AddRange(new List { "additionalParameters" }); } @@ -449,7 +433,6 @@ private ListenarrIndexer BuildListenarrIndexer(IndexerDefinition indexer, Indexe listenarrIndexer.Fields.AddRange(schema.Fields.Where(x => syncFields.Contains(x.Name))); - // Validate required fields exist to avoid NullReferenceExceptions when accessing their values var requiredFieldNames = new List { "baseUrl", "apiPath", "apiKey", "categories" }; var missing = requiredFieldNames.Where(f => listenarrIndexer.Fields.All(x => x.Name != f)).ToList(); @@ -457,7 +440,6 @@ private ListenarrIndexer BuildListenarrIndexer(IndexerDefinition indexer, Indexe { _logger.Debug("Cached schema is missing required fields [{0}]. Attempting to refresh schema from proxy", string.Join(", ", missing)); - // Try a single direct refresh from the proxy in case cache is stale try { var freshSchemas = _listenarrV1Proxy.GetIndexerSchema(Settings); diff --git a/src/NzbDrone.Core/Applications/Listenarr/ListenarrV1Proxy.cs b/src/NzbDrone.Core/Applications/Listenarr/ListenarrV1Proxy.cs index 104b19d98..b60c1dc69 100644 --- a/src/NzbDrone.Core/Applications/Listenarr/ListenarrV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/Listenarr/ListenarrV1Proxy.cs @@ -95,7 +95,6 @@ public List GetIndexerSchema(ListenarrSettings settings) } else { - // Primitive -> wrap into value var item = new Newtonsoft.Json.Linq.JObject { ["name"] = prop.Name, ["value"] = prop.Value }; fieldsArray.Add(item); } @@ -248,7 +247,6 @@ public ValidationFailure TestConnection(ListenarrIndexer indexer, ListenarrSetti } catch (HttpException) { - // Bubble HttpExceptions to be handled by the caller similar to other proxies throw; } }