Skip to content

Commit

Permalink
Protect against Qbittorrent edgecase if users add torrents manually w…
Browse files Browse the repository at this point in the history
…ith Keep top-level folder disabled

(cherry picked from commit 05820ac272ee976fcc0a7b17f3e9cc987cb0d230)
  • Loading branch information
Taloth authored and ta264 committed Dec 13, 2020
1 parent eb50b4f commit 058ab4b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ public override IEnumerable<DownloadClientItem> 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);
Expand Down Expand Up @@ -209,6 +204,19 @@ public override IEnumerable<DownloadClientItem> 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);
}

Expand Down

0 comments on commit 058ab4b

Please sign in to comment.