fix(symlink): strip duplicate torrent name from subpath
torrent.Files[].Path already includes the torrent name as its first component (e.g. "Hijack/Saison 1/file.mkv"), but GetDownloadPath was also initialising torrentPath with torrent.RdName, causing the name to appear twice (e.g. "Hijack/Hijack/Saison 1"). Strip the torrent name prefix from subPath before combining so the resolved path matches the actual rclone mount layout.
This commit is contained in:
parent
b7090eeb3a
commit
1dd7ab9c8e
1 changed files with 30 additions and 2 deletions
|
|
@ -38,7 +38,12 @@ public static class DownloadHelper
|
|||
{
|
||||
subPath = subPath.Trim('/').Trim('\\');
|
||||
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
subPath = StripTorrentNamePrefix(subPath, directory);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(subPath))
|
||||
{
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +92,12 @@ public static class DownloadHelper
|
|||
{
|
||||
subPath = subPath.Trim('/').Trim('\\');
|
||||
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
subPath = StripTorrentNamePrefix(subPath, torrentPath);
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(subPath))
|
||||
{
|
||||
torrentPath = Path.Combine(torrentPath, subPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,4 +127,22 @@ public static class DownloadHelper
|
|||
{
|
||||
return String.Concat(path.Split(Path.GetInvalidPathChars()));
|
||||
}
|
||||
|
||||
private static String StripTorrentNamePrefix(String subPath, String torrentName)
|
||||
{
|
||||
var prefix = torrentName.TrimEnd('/', '\\');
|
||||
|
||||
if (subPath.Equals(prefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
if (subPath.StartsWith(prefix + "/", StringComparison.OrdinalIgnoreCase) ||
|
||||
subPath.StartsWith(prefix + "\\", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return subPath[(prefix.Length + 1)..];
|
||||
}
|
||||
|
||||
return subPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue