From 419cce53f7483df06bc2ca1897c04b9f2e2b6966 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 11 Jun 2023 03:01:42 +0300 Subject: [PATCH] Fixed: (Transmission) Set seed limits in client --- .../Clients/Transmission/TransmissionBase.cs | 44 +------------------ .../Transmission/TransmissionConfig.cs | 2 +- .../Transmission/TransmissionException.cs | 2 +- .../Transmission/TransmissionPriority.cs | 2 +- .../Clients/Transmission/TransmissionProxy.cs | 4 +- .../Transmission/TransmissionResponse.cs | 2 +- .../Transmission/TransmissionTorrent.cs | 4 +- .../Transmission/TransmissionTorrentStatus.cs | 2 +- .../Download/Clients/Vuze/Vuze.cs | 2 +- 9 files changed, 12 insertions(+), 52 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index 5ed105d77..6e723a32a 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -26,51 +26,11 @@ namespace NzbDrone.Core.Download.Clients.Transmission _proxy = proxy; } - protected bool HasReachedSeedLimit(TransmissionTorrent torrent, double? ratio, Lazy config) - { - var isStopped = torrent.Status == TransmissionTorrentStatus.Stopped; - var isSeeding = torrent.Status == TransmissionTorrentStatus.Seeding; - - if (torrent.SeedRatioMode == 1) - { - if (isStopped && ratio.HasValue && ratio >= torrent.SeedRatioLimit) - { - return true; - } - } - else if (torrent.SeedRatioMode == 0) - { - if (isStopped && config.Value.SeedRatioLimited && ratio >= config.Value.SeedRatioLimit) - { - return true; - } - } - - // Transmission doesn't support SeedTimeLimit, use/abuse seed idle limit, but only if it was set per-torrent. - if (torrent.SeedIdleMode == 1) - { - if ((isStopped || isSeeding) && torrent.SecondsSeeding > torrent.SeedIdleLimit * 60) - { - return true; - } - } - else if (torrent.SeedIdleMode == 0) - { - // The global idle limit is a real idle limit, if it's configured then 'Stopped' is enough. - if (isStopped && config.Value.IdleSeedingLimitEnabled) - { - return true; - } - } - - return false; - } - protected override string AddFromMagnetLink(TorrentInfo release, string hash, string magnetLink) { _proxy.AddTorrentFromUrl(magnetLink, GetDownloadDirectory(), Settings); + _proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings); - //_proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings); if (Settings.Priority == (int)TransmissionPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); @@ -82,8 +42,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission protected override string AddFromTorrentFile(TorrentInfo release, string hash, string filename, byte[] fileContent) { _proxy.AddTorrentFromData(fileContent, GetDownloadDirectory(), Settings); + _proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings); - //_proxy.SetTorrentSeedingConfiguration(hash, release.SeedConfiguration, Settings); if (Settings.Priority == (int)TransmissionPriority.First) { _proxy.MoveTorrentToTopInQueue(hash, Settings); diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionConfig.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionConfig.cs index 1b96ca6d3..e987259a9 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionConfig.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionConfig.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace NzbDrone.Core.Download.Clients.Transmission { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionException.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionException.cs index 3b91b4ce3..fe1b01759 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionException.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionException.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.Transmission +namespace NzbDrone.Core.Download.Clients.Transmission { public class TransmissionException : DownloadClientException { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionPriority.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionPriority.cs index 1cf99c501..d896909b3 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionPriority.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionPriority.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.Transmission +namespace NzbDrone.Core.Download.Clients.Transmission { public enum TransmissionPriority { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs index 1172b600a..2c2334f44 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net; using Newtonsoft.Json.Linq; @@ -141,7 +141,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission private TransmissionResponse GetSessionVariables(TransmissionSettings settings) { - // Retrieve transmission information such as the default download directory, bandwith throttling and seed ratio. + // Retrieve transmission information such as the default download directory, bandwidth throttling and seed ratio. return ProcessRequest("session-get", null, settings); } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionResponse.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionResponse.cs index 5d16754b7..68dc7f4d2 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionResponse.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionResponse.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Download.Clients.Transmission { diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrent.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrent.cs index 3abb5d4e8..70ab8a3b9 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrent.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.Transmission +namespace NzbDrone.Core.Download.Clients.Transmission { public class TransmissionTorrent { @@ -9,7 +9,7 @@ public long TotalSize { get; set; } public long LeftUntilDone { get; set; } public bool IsFinished { get; set; } - public int Eta { get; set; } + public long Eta { get; set; } public TransmissionTorrentStatus Status { get; set; } public int SecondsDownloading { get; set; } public int SecondsSeeding { get; set; } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrentStatus.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrentStatus.cs index 13e40f04e..f4683bd1b 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrentStatus.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionTorrentStatus.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.Transmission +namespace NzbDrone.Core.Download.Clients.Transmission { public enum TransmissionTorrentStatus { diff --git a/src/NzbDrone.Core/Download/Clients/Vuze/Vuze.cs b/src/NzbDrone.Core/Download/Clients/Vuze/Vuze.cs index 107b299cb..79f5df0e4 100644 --- a/src/NzbDrone.Core/Download/Clients/Vuze/Vuze.cs +++ b/src/NzbDrone.Core/Download/Clients/Vuze/Vuze.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Download.Clients.Vuze // - A multi-file torrent is downloaded in a job folder and 'outputPath' points to that directory directly. // - A single-file torrent is downloaded in the root folder and 'outputPath' poinst to that root folder. // We have to make sure the return value points to the job folder OR file. - if (outputPath == default || outputPath.FileName == torrent.Name || torrent.FileCount > 1) + if (outputPath.FileName == torrent.Name || torrent.FileCount > 1) { _logger.Trace("Vuze output directory: {0}", outputPath); }