Upgrade downloader to solve memory issue.
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
This commit is contained in:
parent
c349cd2613
commit
dc0541eabf
9 changed files with 41 additions and 75 deletions
|
|
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.0.49] - 2023-11-24
|
||||||
|
### Changed
|
||||||
|
- Fixed memory issue in internal downloader
|
||||||
|
- Changed unpack process to handle cancels
|
||||||
|
|
||||||
## [2.0.48] - 2023-11-15
|
## [2.0.48] - 2023-11-15
|
||||||
### Changed
|
### Changed
|
||||||
- Reverted dockerfile again as the packagemanager still doesn't have .net 8.
|
- Reverted dockerfile again as the packagemanager still doesn't have .net 8.
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
<a class="navbar-item" routerLink="profile"> Profile </a>
|
<a class="navbar-item" routerLink="profile"> Profile </a>
|
||||||
<a class="navbar-item" (click)="logout()"> Logout </a>
|
<a class="navbar-item" (click)="logout()"> Logout </a>
|
||||||
<hr class="navbar-divider" />
|
<hr class="navbar-divider" />
|
||||||
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.48</a>
|
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.49</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "rdt-client",
|
"name": "rdt-client",
|
||||||
"version": "2.0.48",
|
"version": "2.0.49",
|
||||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="AllDebrid.NET" Version="1.0.12" />
|
<PackageReference Include="AllDebrid.NET" Version="1.0.12" />
|
||||||
<PackageReference Include="Aria2.NET" Version="1.0.5" />
|
<PackageReference Include="Aria2.NET" Version="1.0.5" />
|
||||||
<PackageReference Include="Downloader.NET" Version="1.0.8" />
|
<PackageReference Include="Downloader.NET" Version="1.0.9" />
|
||||||
<PackageReference Include="MonoTorrent" Version="2.0.7" />
|
<PackageReference Include="MonoTorrent" Version="2.0.7" />
|
||||||
<PackageReference Include="Premiumize.NET" Version="1.0.4" />
|
<PackageReference Include="Premiumize.NET" Version="1.0.4" />
|
||||||
<PackageReference Include="RD.NET" Version="2.1.4" />
|
<PackageReference Include="RD.NET" Version="2.1.4" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics;
|
using DownloaderNET;
|
||||||
using DownloaderNET;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace RdtClient.Service.Services.Downloaders;
|
namespace RdtClient.Service.Services.Downloaders;
|
||||||
|
|
@ -34,7 +33,7 @@ public class InternalDownloader : IDownloader
|
||||||
|
|
||||||
_downloadService = new Downloader(_uri, _filePath, _downloadConfiguration);
|
_downloadService = new Downloader(_uri, _filePath, _downloadConfiguration);
|
||||||
|
|
||||||
_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
//_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
||||||
|
|
||||||
_downloadService.OnProgress += (chunks, _) =>
|
_downloadService.OnProgress += (chunks, _) =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ public class Torrents
|
||||||
|
|
||||||
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
||||||
{
|
{
|
||||||
download.BytesTotal = unpackClient.BytesTotal;
|
download.BytesTotal = 100;
|
||||||
download.BytesDone = unpackClient.BytesDone;
|
download.BytesDone = unpackClient.Progess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -580,8 +580,8 @@ public class Torrents
|
||||||
|
|
||||||
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
||||||
{
|
{
|
||||||
download.BytesTotal = unpackClient.BytesTotal;
|
download.BytesTotal = 100;
|
||||||
download.BytesDone = unpackClient.BytesDone;
|
download.BytesDone = unpackClient.Progess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
using RdtClient.Data.Models.Data;
|
using System.Diagnostics;
|
||||||
|
using RdtClient.Data.Models.Data;
|
||||||
using RdtClient.Service.Helpers;
|
using RdtClient.Service.Helpers;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Archives.Rar;
|
using SharpCompress.Archives.Rar;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
using SharpCompress.Common;
|
|
||||||
|
|
||||||
namespace RdtClient.Service.Services;
|
namespace RdtClient.Service.Services;
|
||||||
|
|
||||||
|
|
@ -13,17 +13,13 @@ public class UnpackClient
|
||||||
|
|
||||||
public String? Error { get; private set; }
|
public String? Error { get; private set; }
|
||||||
|
|
||||||
public Int64 BytesTotal { get; private set; }
|
public Int32 Progess { get; private set; }
|
||||||
public Int64 BytesDone { get; private set; }
|
|
||||||
|
|
||||||
private readonly Download _download;
|
private readonly Download _download;
|
||||||
private readonly String _destinationPath;
|
private readonly String _destinationPath;
|
||||||
private readonly Torrent _torrent;
|
private readonly Torrent _torrent;
|
||||||
|
|
||||||
private Boolean _cancelled;
|
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
private IArchiveEntry? _rarCurrentEntry;
|
|
||||||
private Dictionary<String, Int64>? _rarfileStatus;
|
|
||||||
|
|
||||||
public UnpackClient(Download download, String destinationPath)
|
public UnpackClient(Download download, String destinationPath)
|
||||||
{
|
{
|
||||||
|
|
@ -34,8 +30,7 @@ public class UnpackClient
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
BytesDone = 0;
|
Progess = 0;
|
||||||
BytesTotal = 0;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -48,9 +43,9 @@ public class UnpackClient
|
||||||
|
|
||||||
Task.Run(async delegate
|
Task.Run(async delegate
|
||||||
{
|
{
|
||||||
if (!_cancelled)
|
if (!_cancellationTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
await Unpack(filePath);
|
await Unpack(filePath, _cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -63,10 +58,10 @@ public class UnpackClient
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
_cancelled = true;
|
_cancellationTokenSource.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Unpack(String filePath)
|
private async Task Unpack(String filePath, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +75,7 @@ public class UnpackClient
|
||||||
|
|
||||||
var archiveEntries = await GetArchiveFiles(filePath);
|
var archiveEntries = await GetArchiveFiles(filePath);
|
||||||
|
|
||||||
if (!archiveEntries.Any(m => m.StartsWith(_torrent.RdName + @"\")) && !archiveEntries.Any(m => m.StartsWith(_torrent.RdName + @"/")))
|
if (!archiveEntries.Any(m => m.StartsWith(_torrent.RdName + @"\")) && !archiveEntries.Any(m => m.StartsWith(_torrent.RdName + "/")))
|
||||||
{
|
{
|
||||||
extractPath = Path.Combine(_destinationPath, _torrent.RdName!);
|
extractPath = Path.Combine(_destinationPath, _torrent.RdName!);
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +92,7 @@ public class UnpackClient
|
||||||
|
|
||||||
if (extractPathTemp != null)
|
if (extractPathTemp != null)
|
||||||
{
|
{
|
||||||
Extract(filePath, extractPathTemp);
|
Extract(filePath, extractPathTemp, cancellationToken);
|
||||||
|
|
||||||
await FileHelper.Delete(filePath);
|
await FileHelper.Delete(filePath);
|
||||||
|
|
||||||
|
|
@ -109,7 +104,7 @@ public class UnpackClient
|
||||||
|
|
||||||
if (File.Exists(mainRarFile))
|
if (File.Exists(mainRarFile))
|
||||||
{
|
{
|
||||||
Extract(mainRarFile, extractPath);
|
Extract(mainRarFile, extractPath, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
await FileHelper.DeleteDirectory(extractPathTemp);
|
await FileHelper.DeleteDirectory(extractPathTemp);
|
||||||
|
|
@ -117,7 +112,7 @@ public class UnpackClient
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Extract(filePath, extractPath);
|
Extract(filePath, extractPath, cancellationToken);
|
||||||
|
|
||||||
await FileHelper.Delete(filePath);
|
await FileHelper.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +127,7 @@ public class UnpackClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IList<String>> GetArchiveFiles(String filePath)
|
private static async Task<IList<String>> GetArchiveFiles(String filePath)
|
||||||
{
|
{
|
||||||
await using Stream stream = File.OpenRead(filePath);
|
await using Stream stream = File.OpenRead(filePath);
|
||||||
|
|
||||||
|
|
@ -148,8 +143,6 @@ public class UnpackClient
|
||||||
archive = RarArchive.Open(stream);
|
archive = RarArchive.Open(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
BytesTotal = archive.TotalSize;
|
|
||||||
|
|
||||||
var entries = archive.Entries
|
var entries = archive.Entries
|
||||||
.Where(entry => !entry.IsDirectory)
|
.Where(entry => !entry.IsDirectory)
|
||||||
.Select(m => m.Key)
|
.Select(m => m.Key)
|
||||||
|
|
@ -160,7 +153,7 @@ public class UnpackClient
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Extract(String filePath, String extractPath)
|
private void Extract(String filePath, String extractPath, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var parts = ArchiveFactory.GetFileParts(filePath);
|
var parts = ArchiveFactory.GetFileParts(filePath);
|
||||||
|
|
||||||
|
|
@ -178,47 +171,16 @@ public class UnpackClient
|
||||||
archive = RarArchive.Open(fi);
|
archive = RarArchive.Open(fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (archive.IsComplete)
|
archive.ExtractToDirectory(extractPath,
|
||||||
{
|
d =>
|
||||||
BytesTotal = archive.TotalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
var entries = archive.Entries.Where(entry => !entry.IsDirectory)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
_rarfileStatus = entries.ToDictionary(entry => entry.Key, _ => 0L);
|
|
||||||
_rarCurrentEntry = null;
|
|
||||||
archive.CompressedBytesRead += ArchiveOnCompressedBytesRead;
|
|
||||||
|
|
||||||
foreach (var entry in entries)
|
|
||||||
{
|
|
||||||
if (_cancelled)
|
|
||||||
{
|
|
||||||
throw new Exception("Task was cancelled");
|
|
||||||
}
|
|
||||||
|
|
||||||
_rarCurrentEntry = entry;
|
|
||||||
|
|
||||||
entry.WriteToDirectory(extractPath,
|
|
||||||
new ExtractionOptions
|
|
||||||
{
|
{
|
||||||
ExtractFullPath = true,
|
Debug.WriteLine(d);
|
||||||
Overwrite = true
|
Progess = (Int32) Math.Round(d);
|
||||||
});
|
},
|
||||||
}
|
cancellationToken: cancellationToken);
|
||||||
|
|
||||||
archive.Dispose();
|
archive.Dispose();
|
||||||
}
|
|
||||||
|
|
||||||
private void ArchiveOnCompressedBytesRead(Object? sender, CompressedBytesReadEventArgs e)
|
GC.Collect();
|
||||||
{
|
|
||||||
if (_rarCurrentEntry == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rarfileStatus![_rarCurrentEntry.Key] = e.CompressedBytesRead;
|
|
||||||
|
|
||||||
BytesDone = _rarfileStatus.Sum(m => m.Value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||||
<Version>2.0.48</Version>
|
<Version>2.0.49</Version>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 16.0.29911.84
|
VisualStudioVersion = 17.8.34316.72
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Web", "RdtClient.Web\RdtClient.Web.csproj", "{A8C7F095-89C6-4CD1-AFB2-27106F470D62}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Web", "RdtClient.Web\RdtClient.Web.csproj", "{A8C7F095-89C6-4CD1-AFB2-27106F470D62}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue