1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-10-02 14:17:19 +02:00

Fixed: Moving files for torrents when Remove Completed is disabled

(cherry picked from commit 78a0def46a4c8628d9bcf6af2701aa35b3f959b9)

Fixed: Moving files on import for usenet clients

(cherry picked from commit 291d792810d071f28c389d100b9642854d7cd70e)
This commit is contained in:
Bogdan 2024-07-31 07:27:19 +03:00 committed by Qstick
parent 364a42424a
commit 29ef75960d
14 changed files with 39 additions and 23 deletions

View File

@ -129,10 +129,8 @@ public override IEnumerable<DownloadClientItem> GetItems()
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(GetOutputPath(torrent))); var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(GetOutputPath(torrent)));
yield return new DownloadClientItem var queueItem = new DownloadClientItem
{ {
CanMoveFiles = false,
CanBeRemoved = torrent.Status == "complete",
Category = null, Category = null,
DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false), DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false),
DownloadId = torrent.InfoHash?.ToUpper(), DownloadId = torrent.InfoHash?.ToUpper(),
@ -146,7 +144,12 @@ public override IEnumerable<DownloadClientItem> GetItems()
Status = status, Status = status,
Title = title, Title = title,
TotalSize = totalLength, TotalSize = totalLength,
CanMoveFiles = false
}; };
queueItem.CanBeRemoved = queueItem.DownloadClientInfo.RemoveCompletedDownloads && torrent.Status == "complete";
yield return queueItem;
} }
} }

View File

@ -89,7 +89,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
{ {
foreach (var item in _scanWatchFolder.GetItems(Settings.WatchFolder, ScanGracePeriod)) foreach (var item in _scanWatchFolder.GetItems(Settings.WatchFolder, ScanGracePeriod))
{ {
yield return new DownloadClientItem var queueItem = new DownloadClientItem
{ {
DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false), DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false),
DownloadId = Definition.Name + "_" + item.DownloadId, DownloadId = Definition.Name + "_" + item.DownloadId,
@ -101,11 +101,14 @@ public override IEnumerable<DownloadClientItem> GetItems()
OutputPath = item.OutputPath, OutputPath = item.OutputPath,
Status = item.Status, Status = item.Status
CanMoveFiles = !Settings.ReadOnly,
CanBeRemoved = !Settings.ReadOnly
}; };
queueItem.CanMoveFiles = queueItem.CanBeRemoved =
queueItem.DownloadClientInfo.RemoveCompletedDownloads &&
!Settings.ReadOnly;
yield return queueItem;
} }
} }

View File

@ -190,6 +190,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
// Here we detect if Deluge is managing the torrent and whether the seed criteria has been met. // Here we detect if Deluge is managing the torrent and whether the seed criteria has been met.
// This allows Radarr to delete the torrent as appropriate. // This allows Radarr to delete the torrent as appropriate.
item.CanMoveFiles = item.CanBeRemoved = item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
torrent.IsAutoManaged && torrent.IsAutoManaged &&
torrent.StopAtRatio && torrent.StopAtRatio &&
torrent.Ratio >= torrent.StopRatio && torrent.Ratio >= torrent.StopRatio &&

View File

@ -88,7 +88,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
} }
} }
var item = new DownloadClientItem() var item = new DownloadClientItem
{ {
Category = Settings.TvCategory, Category = Settings.TvCategory,
DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false), DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false),
@ -99,11 +99,11 @@ public override IEnumerable<DownloadClientItem> GetItems()
RemainingTime = GetRemainingTime(torrent), RemainingTime = GetRemainingTime(torrent),
SeedRatio = GetSeedRatio(torrent), SeedRatio = GetSeedRatio(torrent),
Status = GetStatus(torrent), Status = GetStatus(torrent),
Message = GetMessage(torrent), Message = GetMessage(torrent)
CanMoveFiles = IsFinished(torrent),
CanBeRemoved = IsFinished(torrent)
}; };
item.CanMoveFiles = item.CanBeRemoved = item.DownloadClientInfo.RemoveCompletedDownloads && IsFinished(torrent);
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed) if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
{ {
item.OutputPath = GetOutputPath(outputPath, torrent, serialNumber); item.OutputPath = GetOutputPath(outputPath, torrent, serialNumber);

View File

@ -153,7 +153,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Downloading; item.Status = DownloadItemStatus.Downloading;
} }
if (item.Status == DownloadItemStatus.Completed) if (item.DownloadClientInfo.RemoveCompletedDownloads && item.Status == DownloadItemStatus.Completed)
{ {
// Grab cached seedConfig // Grab cached seedConfig
var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(item.DownloadId); var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(item.DownloadId);
@ -165,7 +165,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
// Check if seed ratio reached // Check if seed ratio reached
item.CanMoveFiles = item.CanBeRemoved = true; item.CanMoveFiles = item.CanBeRemoved = true;
} }
else if (properties.DateFinished != null && properties.DateFinished > 0) else if (properties.DateFinished is > 0)
{ {
// Check if seed time reached // Check if seed time reached
if ((DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds((long)properties.DateFinished)) >= seedConfig.SeedTime) if ((DateTimeOffset.Now - DateTimeOffset.FromUnixTimeSeconds((long)properties.DateFinished)) >= seedConfig.SeedTime)

View File

@ -119,7 +119,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
break; break;
} }
item.CanBeRemoved = item.CanMoveFiles = torrent.Status == FreeboxDownloadTaskStatus.Done; item.CanBeRemoved = item.CanMoveFiles = item.DownloadClientInfo.RemoveCompletedDownloads && torrent.Status == FreeboxDownloadTaskStatus.Done;
queueItems.Add(item); queueItems.Add(item);
} }

View File

@ -103,7 +103,10 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Downloading; item.Status = DownloadItemStatus.Downloading;
} }
item.CanMoveFiles = item.CanBeRemoved = torrent.IsFinished && torrent.State == HadoukenTorrentState.Paused; item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
torrent.IsFinished &&
torrent.State == HadoukenTorrentState.Paused;
items.Add(item); items.Add(item);
} }

View File

@ -225,7 +225,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
foreach (var torrent in torrents) foreach (var torrent in torrents)
{ {
var item = new DownloadClientItem() var item = new DownloadClientItem
{ {
DownloadId = torrent.Hash.ToUpper(), DownloadId = torrent.Hash.ToUpper(),
Category = torrent.Category.IsNotNullOrWhiteSpace() ? torrent.Category : torrent.Label, Category = torrent.Category.IsNotNullOrWhiteSpace() ? torrent.Category : torrent.Label,
@ -239,7 +239,10 @@ public override IEnumerable<DownloadClientItem> GetItems()
// Avoid removing torrents that haven't reached the global max ratio. // Avoid removing torrents that haven't reached the global max ratio.
// Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api). // Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api).
item.CanMoveFiles = item.CanBeRemoved = torrent.State is "pausedUP" or "stoppedUP" && HasReachedSeedLimit(torrent, config); item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
torrent.State is "pausedUP" or "stoppedUP" &&
HasReachedSeedLimit(torrent, config);
switch (torrent.State) switch (torrent.State)
{ {

View File

@ -119,7 +119,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
item.Status = DownloadItemStatus.Downloading; item.Status = DownloadItemStatus.Downloading;
} }
item.CanBeRemoved = HasReachedSeedLimit(torrent, item.SeedRatio, configFunc); item.CanBeRemoved = item.DownloadClientInfo.RemoveCompletedDownloads && HasReachedSeedLimit(torrent, item.SeedRatio, configFunc);
item.CanMoveFiles = item.CanBeRemoved && torrent.Status == TransmissionTorrentStatus.Stopped; item.CanMoveFiles = item.CanBeRemoved && torrent.Status == TransmissionTorrentStatus.Stopped;
items.Add(item); items.Add(item);

View File

@ -185,7 +185,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
// Grab cached seedConfig // Grab cached seedConfig
var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(torrent.Hash); var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(torrent.Hash);
if (torrent.IsFinished && seedConfig != null) if (item.DownloadClientInfo.RemoveCompletedDownloads && torrent.IsFinished && seedConfig != null)
{ {
var canRemove = false; var canRemove = false;

View File

@ -167,6 +167,7 @@ public override IEnumerable<DownloadClientItem> GetItems()
// 'Started' without 'Queued' is when the torrent is 'forced seeding' // 'Started' without 'Queued' is when the torrent is 'forced seeding'
item.CanMoveFiles = item.CanBeRemoved = item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
!torrent.Status.HasFlag(UTorrentTorrentStatus.Queued) && !torrent.Status.HasFlag(UTorrentTorrentStatus.Queued) &&
!torrent.Status.HasFlag(UTorrentTorrentStatus.Started); !torrent.Status.HasFlag(UTorrentTorrentStatus.Started);

View File

@ -38,6 +38,7 @@ public class DownloadClientItemClientInfo
public string Type { get; set; } public string Type { get; set; }
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public bool RemoveCompletedDownloads { get; set; }
public bool HasPostImportCategory { get; set; } public bool HasPostImportCategory { get; set; }
public static DownloadClientItemClientInfo FromDownloadClient<TSettings>( public static DownloadClientItemClientInfo FromDownloadClient<TSettings>(
@ -50,6 +51,7 @@ public static DownloadClientItemClientInfo FromDownloadClient<TSettings>(
Type = downloadClient.Name, Type = downloadClient.Name,
Id = downloadClient.Definition.Id, Id = downloadClient.Definition.Id,
Name = downloadClient.Definition.Name, Name = downloadClient.Definition.Name,
RemoveCompletedDownloads = downloadClient.Definition is DownloadClientDefinition { RemoveCompletedDownloads: true },
HasPostImportCategory = hasPostImportCategory HasPostImportCategory = hasPostImportCategory
}; };
} }

View File

@ -118,7 +118,7 @@ public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownloa
{ {
default: default:
case ImportMode.Auto: case ImportMode.Auto:
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles; copyOnly = downloadClientItem is { CanMoveFiles: false };
break; break;
case ImportMode.Move: case ImportMode.Move:
copyOnly = false; copyOnly = false;