1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-23 22:25:14 -04:00

Aria2 fixes

Fixed: Removing completed downloads from Aria2
Fixed: Return correct path for Aria2 downloads in a job folder
Fixed: Seeding torrents in Aria2 are treated as finished downloading
Closes Sonarr issue 4648

(cherry picked from commit 1d8b711edaa094fb165a90b43f4d9d3534481fa4)
This commit is contained in:
Mark McDowall
2021-09-03 21:41:52 -07:00
committed by Qstick
parent 10f37e0774
commit c8c9db1452
3 changed files with 128 additions and 51 deletions
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnsureThat;
@@ -239,6 +240,33 @@ namespace NzbDrone.Common.Extensions
return null;
}
public static string GetLongestCommonPath(this List<string> paths)
{
var firstPath = paths.First();
var length = firstPath.Length;
for (int i = 1; i < paths.Count; i++)
{
var path = paths[i];
length = Math.Min(length, path.Length);
for (int characterIndex = 0; characterIndex < length; characterIndex++)
{
if (path[characterIndex] != firstPath[characterIndex])
{
length = characterIndex;
break;
}
}
}
var substring = firstPath.Substring(0, length);
var lastSeparatorIndex = substring.LastIndexOfAny(new[] { '/', '\\' });
return substring.Substring(0, lastSeparatorIndex);
}
public static string ProcessNameToExe(this string processName, PlatformType runtime)
{
if (OsInfo.IsWindows || runtime != PlatformType.NetCore)