[TB] Fix Index was out of range error

put < when shouldve put >
This commit is contained in:
Sam Heinz 2024-12-28 01:36:21 +10:00
parent 9a2d59afe0
commit e21dc7279a

View file

@ -40,20 +40,20 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
{ {
foreach (var inner in ae.InnerExceptions) foreach (var inner in ae.InnerExceptions)
{ {
logger.LogError(inner, $"The connection to RealDebrid has failed: {inner.Message}"); logger.LogError(inner, $"The connection to TorBox has failed: {inner.Message}");
} }
throw; throw;
} }
catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException) catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException)
{ {
logger.LogError(ex, $"The connection to RealDebrid has timed out: {ex.Message}"); logger.LogError(ex, $"The connection to TorBox has timed out: {ex.Message}");
throw; throw;
} }
catch (TaskCanceledException ex) catch (TaskCanceledException ex)
{ {
logger.LogError(ex, $"The connection to RealDebrid has timed out: {ex.Message}"); logger.LogError(ex, $"The connection to TorBox has timed out: {ex.Message}");
throw; throw;
} }
@ -161,17 +161,16 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
{ {
var availability = await GetClient().Torrents.GetAvailabilityAsync(hash, listFiles: true); var availability = await GetClient().Torrents.GetAvailabilityAsync(hash, listFiles: true);
if (availability.Data != null || availability.Data?.Count < 0) if (availability.Data != null && availability.Data.Count > 0)
{ {
return (availability.Data[0]?.Files ?? []).Select(file => new TorrentClientAvailableFile return (availability.Data[0]?.Files ?? []).Select(file => new TorrentClientAvailableFile
{ {
Filename = file.Name, Filename = file.Name,
Filesize = file.Size Filesize = file.Size
}) }).ToList();
.ToList();
} }
return []; return new List<TorrentClientAvailableFile>();
} }
public Task SelectFiles(Data.Models.Data.Torrent torrent) public Task SelectFiles(Data.Models.Data.Torrent torrent)