From 05820ac272ee976fcc0a7b17f3e9cc987cb0d230 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 14 Nov 2020 18:49:58 +0100 Subject: [PATCH] Protect against Qbittorrent edgecase if users add torrents manually with Keep top-level folder disabled --- .../Clients/QBittorrent/QBittorrent.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 5a71892f6..4aaaaed13 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -142,11 +142,6 @@ public override IEnumerable GetItems() SeedRatio = torrent.Ratio }; - if (version >= new Version("2.6.1")) - { - item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.ContentPath)); - } - // 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 == "pausedUP" && HasReachedSeedLimit(torrent, config)); @@ -207,6 +202,19 @@ public override IEnumerable GetItems() break; } + if (version >= new Version("2.6.1")) + { + if (torrent.ContentPath != torrent.SavePath) + { + item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.ContentPath)); + } + else if (item.Status == DownloadItemStatus.Completed) + { + item.Status = DownloadItemStatus.Warning; + item.Message = "Unable to import since content path is equal to root download directory, perhaps Keep top-level folder was disabled for this torrent?"; + } + } + queueItems.Add(item); }