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
This commit is contained in:
Mark McDowall
2021-09-03 21:41:52 -07:00
committed by ta264
parent eeb172d3bf
commit 4b8c739b5c
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;
@@ -254,6 +255,33 @@ namespace NzbDrone.Common.Extensions
return processName.ProcessNameToExe(PlatformInfo.Platform);
}
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 GetAppDataPath(this IAppFolderInfo appFolderInfo)
{
return appFolderInfo.AppDataFolder;