Merge pull request #645 from asylumexp/fix/torbox-availability
[TB] Fix Index was out of range error #644
This commit is contained in:
commit
8205e0e652
2 changed files with 14 additions and 21 deletions
|
|
@ -22,7 +22,7 @@
|
|||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.38.0" />
|
||||
<PackageReference Include="TorBox.NET" Version="1.2.1" />
|
||||
<PackageReference Include="TorBox.NET" Version="1.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -40,20 +40,20 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
{
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
@ -120,13 +120,9 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
|
||||
public async Task<String> AddMagnet(String magnetLink)
|
||||
{
|
||||
// var seeding = Settings.Get.Integrations.Default.FinishedAction;
|
||||
var user = await GetClient().User.GetAsync(true);
|
||||
|
||||
// Line is not working right now, will disable seeding and fix in december when I have time again.
|
||||
// var seed = (seeding == TorrentFinishedAction.RemoveAllTorrents || seeding == TorrentFinishedAction.RemoveRealDebrid) ? 3 : 2;
|
||||
|
||||
var seed = 3;
|
||||
var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, seed, false);
|
||||
var result = await GetClient().Torrents.AddMagnetAsync(magnetLink, user.Data?.Settings?.SeedTorrents ?? 3, false);
|
||||
|
||||
if (result.Error == "ACTIVE_LIMIT")
|
||||
{
|
||||
|
|
@ -141,11 +137,9 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
|
||||
public async Task<String> AddFile(Byte[] bytes)
|
||||
{
|
||||
// Line is not working right now, will disable seeding and fix in december when I have time again.
|
||||
// var seed = (seeding == TorrentFinishedAction.RemoveAllTorrents || seeding == TorrentFinishedAction.RemoveRealDebrid) ? 3 : 2;
|
||||
const Int32 seed = 3;
|
||||
var user = await GetClient().User.GetAsync(true);
|
||||
|
||||
var result = await GetClient().Torrents.AddFileAsync(bytes, seed);
|
||||
var result = await GetClient().Torrents.AddFileAsync(bytes, user.Data?.Settings?.SeedTorrents ?? 3);
|
||||
if (result.Error == "ACTIVE_LIMIT")
|
||||
{
|
||||
using var stream = new MemoryStream(bytes);
|
||||
|
|
@ -161,17 +155,16 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
{
|
||||
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
|
||||
{
|
||||
Filename = file.Name,
|
||||
Filesize = file.Size
|
||||
})
|
||||
.ToList();
|
||||
{
|
||||
Filename = file.Name,
|
||||
Filesize = file.Size
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
return [];
|
||||
return new List<TorrentClientAvailableFile>();
|
||||
}
|
||||
|
||||
public Task SelectFiles(Data.Models.Data.Torrent torrent)
|
||||
|
|
|
|||
Loading…
Reference in a new issue