mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 22:17:22 +01:00
Merge branch 'main' into net6
This commit is contained in:
commit
bb8f3fefe6
4 changed files with 7 additions and 9 deletions
2
MareAPI
2
MareAPI
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1ee130413f75da38618f968f4ac813c3205d2adb
|
Subproject commit 21fe024dfb8cecad466dfc8ceef15040300ad342
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Authors></Authors>
|
<Authors></Authors>
|
||||||
<Company></Company>
|
<Company></Company>
|
||||||
<Version>0.3.3</Version>
|
<Version>0.3.4</Version>
|
||||||
<Description></Description>
|
<Description></Description>
|
||||||
<Copyright></Copyright>
|
<Copyright></Copyright>
|
||||||
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace MareSynchronos.WebAPI
|
||||||
await _mareHub!.SendAsync(Api.SendFileDeleteAllFiles);
|
await _mareHub!.SendAsync(Api.SendFileDeleteAllFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> DownloadFile(int downloadId, string hash, CancellationToken ct)
|
private async Task<string> DownloadFile(int downloadId, string hash, Uri downloadUri, CancellationToken ct)
|
||||||
{
|
{
|
||||||
using WebClient wc = new();
|
using WebClient wc = new();
|
||||||
wc.Headers.Add("Authorization", SecretKey);
|
wc.Headers.Add("Authorization", SecretKey);
|
||||||
|
|
@ -58,11 +58,8 @@ namespace MareSynchronos.WebAPI
|
||||||
wc.DownloadProgressChanged += progChanged;
|
wc.DownloadProgressChanged += progChanged;
|
||||||
|
|
||||||
string fileName = Path.GetTempFileName();
|
string fileName = Path.GetTempFileName();
|
||||||
var baseUri = new Uri(Regex.Replace(ApiUri, "^ws", "http"), UriKind.Absolute);
|
|
||||||
var relativeUri = new Uri("cache/" + hash, UriKind.Relative);
|
|
||||||
var fileUri = new Uri(baseUri, relativeUri);
|
|
||||||
|
|
||||||
await wc.DownloadFileTaskAsync(fileUri, fileName);
|
await wc.DownloadFileTaskAsync(downloadUri, fileName);
|
||||||
|
|
||||||
CurrentDownloads[downloadId].Single(f => f.Hash == hash).Transferred = CurrentDownloads[downloadId].Single(f => f.Hash == hash).Total;
|
CurrentDownloads[downloadId].Single(f => f.Hash == hash).Transferred = CurrentDownloads[downloadId].Single(f => f.Hash == hash).Total;
|
||||||
|
|
||||||
|
|
@ -96,7 +93,7 @@ namespace MareSynchronos.WebAPI
|
||||||
foreach (var file in CurrentDownloads[currentDownloadId].Where(f => f.CanBeTransferred))
|
foreach (var file in CurrentDownloads[currentDownloadId].Where(f => f.CanBeTransferred))
|
||||||
{
|
{
|
||||||
var hash = file.Hash;
|
var hash = file.Hash;
|
||||||
var tempFile = await DownloadFile(currentDownloadId, hash, ct);
|
var tempFile = await DownloadFile(currentDownloadId, file.Hash, file.DownloadUri, ct);
|
||||||
if (ct.IsCancellationRequested)
|
if (ct.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
File.Delete(tempFile);
|
File.Delete(tempFile);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using MareSynchronos.API;
|
using MareSynchronos.API;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MareSynchronos.WebAPI.Utils;
|
namespace MareSynchronos.WebAPI.Utils;
|
||||||
|
|
||||||
|
|
@ -37,7 +38,7 @@ public class DownloadFileTransfer : FileTransfer
|
||||||
{
|
{
|
||||||
private DownloadFileDto Dto => (DownloadFileDto)TransferDto;
|
private DownloadFileDto Dto => (DownloadFileDto)TransferDto;
|
||||||
public DownloadFileTransfer(DownloadFileDto dto) : base(dto) { }
|
public DownloadFileTransfer(DownloadFileDto dto) : base(dto) { }
|
||||||
|
public Uri DownloadUri => new(Dto.Url);
|
||||||
public override long Total
|
public override long Total
|
||||||
{
|
{
|
||||||
set { }
|
set { }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue