1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Switched to BigInteger for qbit eta as workaround for api bug, tyvm.

This commit is contained in:
Taloth Saldono 2018-04-29 13:05:43 +02:00
parent 60c73df685
commit 03997e2a0d
4 changed files with 16 additions and 3 deletions

View File

@ -98,6 +98,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />

View File

@ -107,7 +107,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.TotalSize = torrent.Size;
item.DownloadClient = Definition.Name;
item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress));
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
item.RemainingTime = GetRemainingTime(torrent);
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
@ -333,5 +333,15 @@ private void SetInitialState(string hash)
_logger.Warn(ex, "Failed to set inital state for {0}.", hash);
}
}
protected TimeSpan? GetRemainingTime(QBittorrentTorrent torrent)
{
if (torrent.Eta < 0 || torrent.Eta > 365 * 24 * 3600)
{
return null;
}
return TimeSpan.FromSeconds((int)torrent.Eta);
}
}
}

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System.Numerics;
using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.QBittorrent
{
@ -13,7 +14,7 @@ public class QBittorrentTorrent
public double Progress { get; set; } // Torrent progress (%/100)
public ulong Eta { get; set; } // Torrent ETA (seconds)
public BigInteger Eta { get; set; } // Torrent ETA (seconds) (QBit contains a bug exceeding ulong limits)
public string State { get; set; } // Torrent state. See possible values here below

View File

@ -98,6 +98,7 @@
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />