From edf443adfc3a7564caeb63ba7860cca6fd1b37f7 Mon Sep 17 00:00:00 2001 From: Sam Heinz <54530346+asylumexp@users.noreply.github.com> Date: Thu, 13 Mar 2025 00:24:30 +1000 Subject: [PATCH] [TB] fix: move files from hash folder in TB zips to root download dir --- .../Services/UnpackClient.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/server/RdtClient.Service/Services/UnpackClient.cs b/server/RdtClient.Service/Services/UnpackClient.cs index 2724f43..3ca36c9 100644 --- a/server/RdtClient.Service/Services/UnpackClient.cs +++ b/server/RdtClient.Service/Services/UnpackClient.cs @@ -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> GetArchiveFiles(String filePath) { await using Stream stream = File.OpenRead(filePath);