Catch save download errors

This commit is contained in:
Pat Hartl 2023-12-27 17:22:36 -06:00
parent 4c54381a2e
commit e7afbe369b
2 changed files with 14 additions and 1 deletions

View file

@ -82,7 +82,17 @@ namespace LANCommander.SDK
client.DownloadProgressChanged += (s, e) => progressHandler(e);
client.DownloadFileCompleted += (s, e) => completeHandler(e);
client.DownloadFileAsync(new Uri($"{ApiClient.BaseUrl}{route}"), tempFile);
try
{
client.DownloadFileTaskAsync(new Uri($"{ApiClient.BaseUrl}{route}"), tempFile).Wait();
}
catch (Exception ex)
{
if (File.Exists(tempFile))
File.Delete(tempFile);
tempFile = String.Empty;
}
return tempFile;
}

View file

@ -70,6 +70,9 @@ namespace LANCommander.SDK
OnDownloadComplete?.Invoke(complete);
});
if (String.IsNullOrWhiteSpace(destination))
return;
Logger?.LogTrace("Game save archive downloaded to {SaveTempLocation}", destination);
tempFile = destination;