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/),
|
||||
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
|
||||
### Changed
|
||||
- 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" (click)="logout()"> Logout </a>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rdt-client",
|
||||
"version": "2.0.48",
|
||||
"version": "2.0.49",
|
||||
"description": "This is a web interface to manage your torrents on Real-Debrid.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="AllDebrid.NET" Version="1.0.12" />
|
||||
<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="Premiumize.NET" Version="1.0.4" />
|
||||
<PackageReference Include="RD.NET" Version="2.1.4" />
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Diagnostics;
|
||||
using DownloaderNET;
|
||||
using DownloaderNET;
|
||||
using Serilog;
|
||||
|
||||
namespace RdtClient.Service.Services.Downloaders;
|
||||
|
|
@ -34,7 +33,7 @@ public class InternalDownloader : IDownloader
|
|||
|
||||
_downloadService = new Downloader(_uri, _filePath, _downloadConfiguration);
|
||||
|
||||
_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
||||
//_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
||||
|
||||
_downloadService.OnProgress += (chunks, _) =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ public class Torrents
|
|||
|
||||
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
||||
{
|
||||
download.BytesTotal = unpackClient.BytesTotal;
|
||||
download.BytesDone = unpackClient.BytesDone;
|
||||
download.BytesTotal = 100;
|
||||
download.BytesDone = unpackClient.Progess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -580,8 +580,8 @@ public class Torrents
|
|||
|
||||
if (TorrentRunner.ActiveUnpackClients.TryGetValue(download.DownloadId, out var unpackClient))
|
||||
{
|
||||
download.BytesTotal = unpackClient.BytesTotal;
|
||||
download.BytesDone = unpackClient.BytesDone;
|
||||
download.BytesTotal = 100;
|
||||
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 SharpCompress.Archives;
|
||||
using SharpCompress.Archives.Rar;
|
||||
using SharpCompress.Archives.Zip;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace RdtClient.Service.Services;
|
||||
|
||||
|
|
@ -13,17 +13,13 @@ public class UnpackClient
|
|||
|
||||
public String? Error { get; private set; }
|
||||
|
||||
public Int64 BytesTotal { get; private set; }
|
||||
public Int64 BytesDone { get; private set; }
|
||||
public Int32 Progess { get; private set; }
|
||||
|
||||
private readonly Download _download;
|
||||
private readonly String _destinationPath;
|
||||
private readonly Torrent _torrent;
|
||||
|
||||
private Boolean _cancelled;
|
||||
|
||||
private IArchiveEntry? _rarCurrentEntry;
|
||||
private Dictionary<String, Int64>? _rarfileStatus;
|
||||
|
||||
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
public UnpackClient(Download download, String destinationPath)
|
||||
{
|
||||
|
|
@ -34,8 +30,7 @@ public class UnpackClient
|
|||
|
||||
public void Start()
|
||||
{
|
||||
BytesDone = 0;
|
||||
BytesTotal = 0;
|
||||
Progess = 0;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -48,9 +43,9 @@ public class UnpackClient
|
|||
|
||||
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()
|
||||
{
|
||||
_cancelled = true;
|
||||
_cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
private async Task Unpack(String filePath)
|
||||
private async Task Unpack(String filePath, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -80,7 +75,7 @@ public class UnpackClient
|
|||
|
||||
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!);
|
||||
}
|
||||
|
|
@ -97,7 +92,7 @@ public class UnpackClient
|
|||
|
||||
if (extractPathTemp != null)
|
||||
{
|
||||
Extract(filePath, extractPathTemp);
|
||||
Extract(filePath, extractPathTemp, cancellationToken);
|
||||
|
||||
await FileHelper.Delete(filePath);
|
||||
|
||||
|
|
@ -109,7 +104,7 @@ public class UnpackClient
|
|||
|
||||
if (File.Exists(mainRarFile))
|
||||
{
|
||||
Extract(mainRarFile, extractPath);
|
||||
Extract(mainRarFile, extractPath, cancellationToken);
|
||||
}
|
||||
|
||||
await FileHelper.DeleteDirectory(extractPathTemp);
|
||||
|
|
@ -117,7 +112,7 @@ public class UnpackClient
|
|||
}
|
||||
else
|
||||
{
|
||||
Extract(filePath, extractPath);
|
||||
Extract(filePath, extractPath, cancellationToken);
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -148,8 +143,6 @@ public class UnpackClient
|
|||
archive = RarArchive.Open(stream);
|
||||
}
|
||||
|
||||
BytesTotal = archive.TotalSize;
|
||||
|
||||
var entries = archive.Entries
|
||||
.Where(entry => !entry.IsDirectory)
|
||||
.Select(m => m.Key)
|
||||
|
|
@ -160,7 +153,7 @@ public class UnpackClient
|
|||
return entries;
|
||||
}
|
||||
|
||||
private void Extract(String filePath, String extractPath)
|
||||
private void Extract(String filePath, String extractPath, CancellationToken cancellationToken)
|
||||
{
|
||||
var parts = ArchiveFactory.GetFileParts(filePath);
|
||||
|
||||
|
|
@ -177,48 +170,17 @@ public class UnpackClient
|
|||
{
|
||||
archive = RarArchive.Open(fi);
|
||||
}
|
||||
|
||||
if (archive.IsComplete)
|
||||
{
|
||||
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
|
||||
archive.ExtractToDirectory(extractPath,
|
||||
d =>
|
||||
{
|
||||
ExtractFullPath = true,
|
||||
Overwrite = true
|
||||
});
|
||||
}
|
||||
|
||||
Debug.WriteLine(d);
|
||||
Progess = (Int32) Math.Round(d);
|
||||
},
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
archive.Dispose();
|
||||
}
|
||||
|
||||
private void ArchiveOnCompressedBytesRead(Object? sender, CompressedBytesReadEventArgs e)
|
||||
{
|
||||
if (_rarCurrentEntry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_rarfileStatus![_rarCurrentEntry.Key] = e.CompressedBytesRead;
|
||||
|
||||
BytesDone = _rarfileStatus.Sum(m => m.Value);
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UserSecretsId>94c24cba-f03f-4453-a671-3640b517c573</UserSecretsId>
|
||||
<Version>2.0.48</Version>
|
||||
<Version>2.0.49</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29911.84
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34316.72
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RdtClient.Web", "RdtClient.Web\RdtClient.Web.csproj", "{A8C7F095-89C6-4CD1-AFB2-27106F470D62}"
|
||||
EndProject
|
||||
|
|
|
|||
Loading…
Reference in a new issue