Skip to content

Commit

Permalink
Fixed: qBittorrent not correctly handling retention during testing
Browse files Browse the repository at this point in the history
(cherry picked from commit 588372fd950fc85f5e9a4275fbcb423b247ed0ee)
  • Loading branch information
carlos-sarmiento authored and mynameisbogdan committed Mar 28, 2024
1 parent a8648fd commit 1d0de51
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,20 @@ public override DownloadClientInfo GetStatus()
}
}

var minimumRetention = 60 * 24 * 14;

return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) },
RemovesCompletedDownloads = (config.MaxRatioEnabled || (config.MaxSeedingTimeEnabled && config.MaxSeedingTime < minimumRetention)) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles)
RemovesCompletedDownloads = RemovesCompletedDownloads(config)
};
}

private bool RemovesCompletedDownloads(QBittorrentPreferences config)
{
var minimumRetention = 60 * 24 * 14; // 14 days in minutes
return (config.MaxRatioEnabled || (config.MaxSeedingTimeEnabled && config.MaxSeedingTime < minimumRetention)) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles);
}

protected override void Test(List<ValidationFailure> failures)
{
failures.AddIfNotNull(TestConnection());
Expand Down Expand Up @@ -445,7 +449,7 @@ private ValidationFailure TestConnection()

// Complain if qBittorrent is configured to remove torrents on max ratio
var config = Proxy.GetConfig(Settings);
if ((config.MaxRatioEnabled || config.MaxSeedingTimeEnabled) && (config.MaxRatioAction == QBittorrentMaxRatioAction.Remove || config.MaxRatioAction == QBittorrentMaxRatioAction.DeleteFiles))
if (RemovesCompletedDownloads(config))
{
return new NzbDroneValidationFailure(string.Empty, "qBittorrent is configured to remove torrents when they reach their Share Ratio Limit")
{
Expand Down

0 comments on commit 1d0de51

Please sign in to comment.