mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-07 04:00:32 +02:00
Fix null safety, equality contract, and silent HTTP errors in Qui application
- Prevent NullReferenceException in UpdateIndexer when indexerMapping is null - Normalize Categories comparison in QuiIndexer.Equals for null/empty symmetry and add GetHashCode override to maintain equality/hash contract - Check response status in RemoveIndexer so failed DELETEs raise HttpException Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bbc828500a
commit
15eed25107
3 changed files with 17 additions and 3 deletions
|
|
@ -145,7 +145,7 @@ public override void UpdateIndexer(IndexerDefinition indexer, bool forceSync = f
|
|||
|
||||
var quiIndexer = BuildQuiIndexer(indexer, indexerCapabilities, indexerMapping?.RemoteIndexerId ?? 0);
|
||||
|
||||
var remoteIndexer = _quiProxy.GetIndexer(indexerMapping.RemoteIndexerId, Settings);
|
||||
var remoteIndexer = _quiProxy.GetIndexer(indexerMapping?.RemoteIndexerId ?? 0, Settings);
|
||||
|
||||
if (remoteIndexer != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -58,13 +59,21 @@ public bool Equals(QuiIndexer other)
|
|||
return false;
|
||||
}
|
||||
|
||||
var thisCategories = (Categories ?? Enumerable.Empty<string>()).OrderBy(c => c);
|
||||
var otherCategories = (other.Categories ?? Enumerable.Empty<string>()).OrderBy(c => c);
|
||||
|
||||
return other.BaseUrl == BaseUrl &&
|
||||
other.ApiKey == ApiKey &&
|
||||
other.Name == Name &&
|
||||
other.Enabled == Enabled &&
|
||||
other.Priority == Priority &&
|
||||
other.IndexerId == IndexerId &&
|
||||
other.Categories?.OrderBy(c => c).SequenceEqual(Categories?.OrderBy(c => c) ?? Enumerable.Empty<string>()) == true;
|
||||
otherCategories.SequenceEqual(thisCategories);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(BaseUrl, ApiKey, Name, Enabled, Priority, IndexerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,12 @@ public QuiIndexer UpdateIndexer(QuiIndexer indexer, QuiSettings settings)
|
|||
public void RemoveIndexer(int indexerId, QuiSettings settings)
|
||||
{
|
||||
var request = BuildRequest(settings, $"{AppIndexerApiRoute}/{indexerId}", HttpMethod.Delete);
|
||||
_httpClient.Execute(request);
|
||||
var response = _httpClient.Execute(request);
|
||||
|
||||
if ((int)response.StatusCode >= 300)
|
||||
{
|
||||
throw new HttpException(response);
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationFailure TestConnection(QuiSettings settings)
|
||||
|
|
|
|||
Loading…
Reference in a new issue