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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user