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)
pull/10263/head
Bogdan 4 months ago committed by Qstick
parent 364a42424a
commit 29ef75960d

@ -129,10 +129,8 @@ namespace NzbDrone.Core.Download.Clients.Aria2
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,
DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false),
DownloadId = torrent.InfoHash?.ToUpper(),
@ -146,7 +144,12 @@ namespace NzbDrone.Core.Download.Clients.Aria2
Status = status,
Title = title,
TotalSize = totalLength,
CanMoveFiles = false
};
queueItem.CanBeRemoved = queueItem.DownloadClientInfo.RemoveCompletedDownloads && torrent.Status == "complete";
yield return queueItem;
}
}

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

@ -190,6 +190,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
// 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.
item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
torrent.IsAutoManaged &&
torrent.StopAtRatio &&
torrent.Ratio >= torrent.StopRatio &&

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

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

@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.FreeboxDownload
break;
}
item.CanBeRemoved = item.CanMoveFiles = torrent.Status == FreeboxDownloadTaskStatus.Done;
item.CanBeRemoved = item.CanMoveFiles = item.DownloadClientInfo.RemoveCompletedDownloads && torrent.Status == FreeboxDownloadTaskStatus.Done;
queueItems.Add(item);
}

@ -103,7 +103,10 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
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);
}

@ -225,7 +225,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
foreach (var torrent in torrents)
{
var item = new DownloadClientItem()
var item = new DownloadClientItem
{
DownloadId = torrent.Hash.ToUpper(),
Category = torrent.Category.IsNotNullOrWhiteSpace() ? torrent.Category : torrent.Label,
@ -239,7 +239,10 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
// 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).
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)
{

@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
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;
items.Add(item);

@ -185,7 +185,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
// Grab cached seedConfig
var seedConfig = _downloadSeedConfigProvider.GetSeedConfiguration(torrent.Hash);
if (torrent.IsFinished && seedConfig != null)
if (item.DownloadClientInfo.RemoveCompletedDownloads && torrent.IsFinished && seedConfig != null)
{
var canRemove = false;

@ -167,6 +167,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
// 'Started' without 'Queued' is when the torrent is 'forced seeding'
item.CanMoveFiles = item.CanBeRemoved =
item.DownloadClientInfo.RemoveCompletedDownloads &&
!torrent.Status.HasFlag(UTorrentTorrentStatus.Queued) &&
!torrent.Status.HasFlag(UTorrentTorrentStatus.Started);

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

@ -118,7 +118,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
{
default:
case ImportMode.Auto:
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
copyOnly = downloadClientItem is { CanMoveFiles: false };
break;
case ImportMode.Move:
copyOnly = false;

Loading…
Cancel
Save