mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
New: Removing Flood downloads when seeding criteria have been met
closes #4492
This commit is contained in:
parent
fe8f319f7b
commit
c8ad01e38e
@ -36,7 +36,7 @@ private void MoveRemoveSettings(IDbConnection conn, IDbTransaction tran)
|
|||||||
removeFailedDownloads = true;
|
removeFailedDownloads = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation = \"RTorrent\" THEN 0 ELSE ? END), RemoveFailedDownloads = ?"))
|
using (var updateClientCmd = conn.CreateCommand(tran, $"UPDATE DownloadClients SET RemoveCompletedDownloads = (CASE WHEN Implementation IN (\"RTorrent\", \"Flood\") THEN 0 ELSE ? END), RemoveFailedDownloads = ?"))
|
||||||
{
|
{
|
||||||
updateClientCmd.AddParameter(removeCompletedDownloads ? 1 : 0);
|
updateClientCmd.AddParameter(removeCompletedDownloads ? 1 : 0);
|
||||||
updateClientCmd.AddParameter(removeFailedDownloads ? 1 : 0);
|
updateClientCmd.AddParameter(removeFailedDownloads ? 1 : 0);
|
||||||
|
@ -18,8 +18,10 @@ namespace NzbDrone.Core.Download.Clients.Flood
|
|||||||
public class Flood : TorrentClientBase<FloodSettings>
|
public class Flood : TorrentClientBase<FloodSettings>
|
||||||
{
|
{
|
||||||
private readonly IFloodProxy _proxy;
|
private readonly IFloodProxy _proxy;
|
||||||
|
private readonly IDownloadSeedConfigProvider _downloadSeedConfigProvider;
|
||||||
|
|
||||||
public Flood(IFloodProxy proxy,
|
public Flood(IFloodProxy proxy,
|
||||||
|
IDownloadSeedConfigProvider downloadSeedConfigProvider,
|
||||||
ITorrentFileInfoReader torrentFileInfoReader,
|
ITorrentFileInfoReader torrentFileInfoReader,
|
||||||
IHttpClient httpClient,
|
IHttpClient httpClient,
|
||||||
IConfigService configService,
|
IConfigService configService,
|
||||||
@ -29,6 +31,7 @@ public Flood(IFloodProxy proxy,
|
|||||||
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
|
||||||
{
|
{
|
||||||
_proxy = proxy;
|
_proxy = proxy;
|
||||||
|
_downloadSeedConfigProvider = downloadSeedConfigProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> HandleTags(RemoteEpisode remoteEpisode, FloodSettings settings)
|
private static IEnumerable<string> HandleTags(RemoteEpisode remoteEpisode, FloodSettings settings)
|
||||||
@ -77,7 +80,7 @@ private static IEnumerable<string> HandleTags(RemoteEpisode remoteEpisode, Flood
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override string Name => "Flood";
|
public override string Name => "Flood";
|
||||||
public override ProviderMessage Message => new ProviderMessage("Sonarr is unable to remove torrents that have finished seeding when using Flood", ProviderMessageType.Warning);
|
public override ProviderMessage Message => new ProviderMessage("Sonarr will handle automatic removal of torrents based on the current seed criteria in Settings -> Indexers", ProviderMessageType.Info);
|
||||||
|
|
||||||
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
|
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
|
||||||
{
|
{
|
||||||
@ -119,6 +122,8 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
|||||||
TotalSize = properties.SizeBytes,
|
TotalSize = properties.SizeBytes,
|
||||||
SeedRatio = properties.Ratio,
|
SeedRatio = properties.Ratio,
|
||||||
Message = properties.Message,
|
Message = properties.Message,
|
||||||
|
CanMoveFiles = false,
|
||||||
|
CanBeRemoved = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (properties.Eta > 0)
|
if (properties.Eta > 0)
|
||||||
@ -143,7 +148,28 @@ public override IEnumerable<DownloadClientItem> GetItems()
|
|||||||
item.Status = DownloadItemStatus.Paused;
|
item.Status = DownloadItemStatus.Paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.CanMoveFiles = item.CanBeRemoved = false;
|
if (item.Status == DownloadItemStatus.Completed)
|
||||||
|
{
|
||||||
|
// Grab cached seedConfig
|
||||||
|
var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(item.DownloadId);
|
||||||
|
|
||||||
|
if (seedConfig != null)
|
||||||
|
{
|
||||||
|
if (item.SeedRatio >= seedConfig.Ratio)
|
||||||
|
{
|
||||||
|
// Check if seed ratio reached
|
||||||
|
item.CanMoveFiles = item.CanBeRemoved = true;
|
||||||
|
}
|
||||||
|
else if (properties.DateFinished != null && properties.DateFinished > 0)
|
||||||
|
{
|
||||||
|
// Check if seed time reached
|
||||||
|
if ((DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds(properties.DateFinished)) >= seedConfig.SeedTime)
|
||||||
|
{
|
||||||
|
item.CanMoveFiles = item.CanBeRemoved = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
items.Add(item);
|
items.Add(item);
|
||||||
}
|
}
|
||||||
|
@ -31,5 +31,9 @@ public sealed class Torrent
|
|||||||
|
|
||||||
[JsonProperty(PropertyName = "tags")]
|
[JsonProperty(PropertyName = "tags")]
|
||||||
public List<string> Tags { get; set; }
|
public List<string> Tags { get; set; }
|
||||||
|
|
||||||
|
// added in Flood 4.5
|
||||||
|
[JsonProperty(PropertyName = "dateFinished")]
|
||||||
|
public long? DateFinished { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user