mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -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
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;
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user