mirror of
https://github.com/Radarr/Radarr
synced 2026-01-24 08:23:54 +01:00
Merge pull request #49 from cheir-mneme/fix/technical-debt-cleanup
fix: Remaining technical debt bugs (Bug-001, Bug-006)
This commit is contained in:
commit
7b4f77604f
9 changed files with 45 additions and 11 deletions
|
|
@ -421,7 +421,7 @@ public bool Equals(OsPath other, bool ignoreTrailingSlash)
|
|||
{
|
||||
if (left.Kind != right.Kind && right.Kind != OsPathKind.Unknown)
|
||||
{
|
||||
throw new Exception(string.Format("Cannot combine OsPaths of different platforms ('{0}' + '{1}')", left, right));
|
||||
throw new PathCombinationException("Cannot combine OsPaths of different platforms ('{0}' + '{1}')", left, right);
|
||||
}
|
||||
|
||||
if (right.IsEmpty)
|
||||
|
|
|
|||
17
src/NzbDrone.Common/Disk/PathCombinationException.cs
Normal file
17
src/NzbDrone.Common/Disk/PathCombinationException.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Common.Disk
|
||||
{
|
||||
public class PathCombinationException : NzbDroneException
|
||||
{
|
||||
public PathCombinationException(string message, params object[] args)
|
||||
: base(message, args)
|
||||
{
|
||||
}
|
||||
|
||||
public PathCombinationException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -280,6 +280,8 @@ private async ValueTask<Stream> onConnect(SocketsHttpConnectionContext context,
|
|||
// This issue is being tracked at https://github.com/dotnet/runtime/issues/26177 and expected to be fixed in .NET 6.
|
||||
if (useIPv6)
|
||||
{
|
||||
CancellationTokenSource quickFailCts = null;
|
||||
CancellationTokenSource linkedTokenSource = null;
|
||||
try
|
||||
{
|
||||
var localToken = cancellationToken;
|
||||
|
|
@ -287,8 +289,8 @@ private async ValueTask<Stream> onConnect(SocketsHttpConnectionContext context,
|
|||
if (!hasResolvedIPv6Availability)
|
||||
{
|
||||
// to make things move fast, use a very low timeout for the initial ipv6 attempt.
|
||||
var quickFailCts = new CancellationTokenSource(connection_establish_timeout);
|
||||
var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, quickFailCts.Token);
|
||||
quickFailCts = new CancellationTokenSource(connection_establish_timeout);
|
||||
linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, quickFailCts.Token);
|
||||
|
||||
localToken = linkedTokenSource.Token;
|
||||
}
|
||||
|
|
@ -305,6 +307,8 @@ private async ValueTask<Stream> onConnect(SocketsHttpConnectionContext context,
|
|||
finally
|
||||
{
|
||||
hasResolvedIPv6Availability = true;
|
||||
linkedTokenSource?.Dispose();
|
||||
quickFailCts?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ protected override HttpRequest GetHttpRequest()
|
|||
// Use IMDb list Export for user lists to bypass RadarrAPI caching
|
||||
if (Settings.ListId.StartsWith("ls", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new Exception("IMDb lists of the form 'ls12345678' are no longer supported. Feel free to remove this list after you review your Clean Library Level.");
|
||||
throw new NotSupportedException("IMDb lists of the form 'ls12345678' are no longer supported. Feel free to remove this list after you review your Clean Library Level.");
|
||||
}
|
||||
|
||||
var request = RequestBuilder.Create()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,10 @@ protected virtual string GetMagnetUrl(XElement item)
|
|||
if (PeersElementName.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
var itempeers = item.FindDecendants(PeersElementName).SingleOrDefault();
|
||||
return int.Parse(itempeers.Value);
|
||||
if (itempeers != null)
|
||||
{
|
||||
return int.Parse(itempeers.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public void Handle(ApplicationShutdownRequested message)
|
|||
{
|
||||
_logger.Info("Shutting down scheduler");
|
||||
_cancellationTokenSource.Cancel(true);
|
||||
_cancellationTokenSource.Dispose();
|
||||
Timer.Stop();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
|
@ -141,7 +142,7 @@ private string GetMovieCoverPath(int movieId)
|
|||
return Path.Combine(_coverRootFolder, movieId.ToString());
|
||||
}
|
||||
|
||||
private bool EnsureCovers(Movie movie)
|
||||
private async Task<bool> EnsureCoversAsync(Movie movie)
|
||||
{
|
||||
var updated = false;
|
||||
var toResize = new List<Tuple<MediaCover, bool>>();
|
||||
|
|
@ -184,7 +185,7 @@ private bool EnsureCovers(Movie movie)
|
|||
|
||||
try
|
||||
{
|
||||
_semaphore.Wait();
|
||||
await _semaphore.WaitAsync();
|
||||
|
||||
foreach (var tuple in toResize)
|
||||
{
|
||||
|
|
@ -261,9 +262,9 @@ private static string GetExtension(MediaCoverTypes coverType)
|
|||
};
|
||||
}
|
||||
|
||||
public void HandleAsync(MovieUpdatedEvent message)
|
||||
public async void HandleAsync(MovieUpdatedEvent message)
|
||||
{
|
||||
var updated = EnsureCovers(message.Movie);
|
||||
var updated = await EnsureCoversAsync(message.Movie);
|
||||
|
||||
_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie, updated));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ public void Handle(ApplicationShutdownRequested message)
|
|||
{
|
||||
_logger.Info("Shutting down task execution");
|
||||
_cancellationTokenSource.Cancel(true);
|
||||
_cancellationTokenSource.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public abstract class IntegrationTestBase
|
|||
private List<SignalRMessage> _signalRReceived;
|
||||
|
||||
private HubConnection _signalrConnection;
|
||||
private CancellationTokenSource _signalrCts;
|
||||
|
||||
protected IEnumerable<SignalRMessage> SignalRMessages => _signalRReceived;
|
||||
|
||||
|
|
@ -148,6 +149,12 @@ public async Task IntegrationTearDown()
|
|||
_signalRReceived = new List<SignalRMessage>();
|
||||
}
|
||||
|
||||
if (_signalrCts != null)
|
||||
{
|
||||
_signalrCts.Dispose();
|
||||
_signalrCts = null;
|
||||
}
|
||||
|
||||
if (Directory.Exists(TempDirectory))
|
||||
{
|
||||
try
|
||||
|
|
@ -174,11 +181,11 @@ protected async Task ConnectSignalR()
|
|||
_signalRReceived = new List<SignalRMessage>();
|
||||
_signalrConnection = new HubConnectionBuilder().WithUrl("http://localhost:7878/signalr/messages").Build();
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
_signalrCts = new CancellationTokenSource();
|
||||
|
||||
_signalrConnection.Closed += e =>
|
||||
{
|
||||
cts.Cancel();
|
||||
_signalrCts.Cancel();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue