mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 16:47:22 +01:00
fix for crashes on unloading mare while downloading files
This commit is contained in:
parent
8716352116
commit
4ca2419f46
2 changed files with 14 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
<Version>0.2.12.0</Version>
|
||||
<Version>0.2.13.0</Version>
|
||||
<Description></Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
||||
|
|
|
|||
|
|
@ -38,10 +38,20 @@ namespace MareSynchronos.WebAPI
|
|||
private async Task<string> DownloadFile(int downloadId, string hash, CancellationToken ct)
|
||||
{
|
||||
using WebClient wc = new();
|
||||
wc.DownloadProgressChanged += (s, e) =>
|
||||
DownloadProgressChangedEventHandler progChanged = (s, e) =>
|
||||
{
|
||||
CurrentDownloads[downloadId].Single(f => f.Hash == hash).Transferred = e.BytesReceived;
|
||||
try
|
||||
{
|
||||
CurrentDownloads[downloadId].Single(f => f.Hash == hash).Transferred = e.BytesReceived;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Could not set download progress for " + hash);
|
||||
Logger.Warn(ex.Message);
|
||||
Logger.Warn(ex.StackTrace ?? string.Empty);
|
||||
}
|
||||
};
|
||||
wc.DownloadProgressChanged += progChanged;
|
||||
|
||||
string fileName = Path.GetTempFileName();
|
||||
var baseUri = new Uri(ApiUri.Replace("wss", "https"), UriKind.Absolute);
|
||||
|
|
@ -52,6 +62,7 @@ namespace MareSynchronos.WebAPI
|
|||
|
||||
CurrentDownloads[downloadId].Single(f => f.Hash == hash).Transferred = CurrentDownloads[downloadId].Single(f => f.Hash == hash).Total;
|
||||
|
||||
wc.DownloadProgressChanged -= progChanged;
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue