mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-11 06:22:52 +00: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:
parent
d2bd9b4849
commit
0216f46b37
13 changed files with 36 additions and 20 deletions
|
@ -127,10 +127,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(),
|
||||
|
@ -144,7 +142,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,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,
|
||||
|
@ -99,11 +99,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,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 drone to delete the torrent as appropriate.
|
||||
item.CanMoveFiles = item.CanBeRemoved =
|
||||
item.DownloadClientInfo.RemoveCompletedDownloads &&
|
||||
torrent.IsAutoManaged &&
|
||||
torrent.StopAtRatio &&
|
||||
torrent.Ratio >= torrent.StopRatio &&
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
|||
}
|
||||
}
|
||||
|
||||
var item = new DownloadClientItem()
|
||||
var item = new DownloadClientItem
|
||||
{
|
||||
Category = Settings.MusicCategory,
|
||||
DownloadClientInfo = DownloadClientItemClientInfo.FromDownloadClient(this, false),
|
||||
|
@ -97,11 +97,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);
|
||||
|
|
|
@ -143,7 +143,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);
|
||||
|
@ -155,7 +155,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)
|
||||
|
|
|
@ -116,7 +116,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);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,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);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,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)
|
||||
{
|
||||
|
|
|
@ -117,7 +117,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);
|
||||
|
|
|
@ -180,7 +180,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;
|
||||
|
||||
|
|
|
@ -165,6 +165,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
|
||||
};
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|||
{
|
||||
default:
|
||||
case ImportMode.Auto:
|
||||
copyOnly = downloadClientItem != null && !downloadClientItem.CanMoveFiles;
|
||||
copyOnly = downloadClientItem is { CanMoveFiles: false };
|
||||
break;
|
||||
case ImportMode.Move:
|
||||
copyOnly = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue