[TB] fix: move MoveHashDirectoryUpTB to TorBoxTorrentClient
This commit is contained in:
parent
bf023b333b
commit
fd7bc529c8
2 changed files with 26 additions and 25 deletions
|
|
@ -344,7 +344,30 @@ public class TorBoxTorrentClient(ILogger<TorBoxTorrentClient> logger, IHttpClien
|
|||
|
||||
return Map(result!);
|
||||
}
|
||||
|
||||
|
||||
public static void MoveHashDirectoryUpTB(String extractPath, Torrent _torrent)
|
||||
{
|
||||
var hashDir = Path.Combine(extractPath, _torrent.Hash);
|
||||
if (Directory.Exists(hashDir))
|
||||
{
|
||||
var innerFolder = Directory.GetDirectories(hashDir)[0];
|
||||
|
||||
foreach (var file in Directory.GetFiles(innerFolder))
|
||||
{
|
||||
var destFile = Path.Combine(extractPath, Path.GetFileName(file));
|
||||
File.Move(file, destFile);
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(innerFolder))
|
||||
{
|
||||
var destDir = Path.Combine(extractPath, Path.GetFileName(dir));
|
||||
Directory.Move(dir, destDir);
|
||||
}
|
||||
|
||||
Directory.Delete(hashDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(String message, Torrent? torrent = null)
|
||||
{
|
||||
if (torrent != null)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Diagnostics;
|
||||
using RdtClient.Data.Models.Data;
|
||||
using RdtClient.Service.Helpers;
|
||||
using RdtClient.Service.Services.TorrentClients;
|
||||
using SharpCompress.Archives;
|
||||
using SharpCompress.Archives.Rar;
|
||||
using SharpCompress.Archives.Zip;
|
||||
|
|
@ -105,7 +106,7 @@ public class UnpackClient(Download download, String destinationPath)
|
|||
|
||||
if (Settings.Get.Provider.Provider == Data.Enums.Provider.TorBox)
|
||||
{
|
||||
MoveHashDirectoryUpTB(extractPath);
|
||||
TorBoxTorrentClient.MoveHashDirectoryUpTB(extractPath, _torrent);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -119,29 +120,6 @@ public class UnpackClient(Download download, String destinationPath)
|
|||
}
|
||||
|
||||
|
||||
private void MoveHashDirectoryUpTB(String extractPath)
|
||||
{
|
||||
var hashDir = Path.Combine(extractPath, _torrent.Hash);
|
||||
if (Directory.Exists(hashDir))
|
||||
{
|
||||
var innerFolder = Directory.GetDirectories(hashDir)[0];
|
||||
|
||||
foreach (var file in Directory.GetFiles(innerFolder))
|
||||
{
|
||||
var destFile = Path.Combine(extractPath, Path.GetFileName(file));
|
||||
File.Move(file, destFile);
|
||||
}
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(innerFolder))
|
||||
{
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue