[TB] fix: move files from hash folder in TB zips to root download dir

This commit is contained in:
Sam Heinz 2025-03-13 00:24:30 +10:00
parent 10176357e4
commit edf443adfc

View file

@ -80,6 +80,11 @@ public class UnpackClient(Download download, String destinationPath)
{
Extract(filePath, extractPathTemp, cancellationToken);
if (Settings.Get.Provider.Provider == Data.Enums.Provider.TorBox)
{
MoveHashDirectoryUpTB(extractPathTemp);
}
await FileHelper.Delete(filePath);
var rarFiles = Directory.GetFiles(extractPathTemp, "*.r00", SearchOption.TopDirectoryOnly);
@ -91,6 +96,11 @@ public class UnpackClient(Download download, String destinationPath)
if (File.Exists(mainRarFile))
{
Extract(mainRarFile, extractPath, cancellationToken);
if (Settings.Get.Provider.Provider == Data.Enums.Provider.TorBox)
{
MoveHashDirectoryUpTB(extractPath);
}
}
await FileHelper.DeleteDirectory(extractPathTemp);
@ -100,6 +110,11 @@ public class UnpackClient(Download download, String destinationPath)
{
Extract(filePath, extractPath, cancellationToken);
if (Settings.Get.Provider.Provider == Data.Enums.Provider.TorBox)
{
MoveHashDirectoryUpTB(extractPath);
}
await FileHelper.Delete(filePath);
}
}
@ -113,6 +128,28 @@ public class UnpackClient(Download download, String destinationPath)
}
}
private void MoveHashDirectoryUpTB(string extractPath)
{
var hashDir = Path.Combine(extractPath, _torrent.Hash);
if (Directory.Exists(hashDir))
{
foreach (var file in Directory.GetFiles(hashDir))
{
var destFile = Path.Combine(extractPath, Path.GetFileName(file));
File.Move(file, destFile);
}
foreach (var dir in Directory.GetDirectories(hashDir))
{
var destDir = Path.Combine(extractPath, Path.GetFileName(dir));
Directory.Move(dir, destDir);
}
Directory.Delete(hashDir, true);
}
}
private static async Task<IList<String>> GetArchiveFiles(String filePath)
{
await using Stream stream = File.OpenRead(filePath);