From e7afbe369ba250b701ca3d5a3587f608b2aa2bf0 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Wed, 27 Dec 2023 17:22:36 -0600 Subject: [PATCH] Catch save download errors --- LANCommander.SDK/Client.cs | 12 +++++++++++- LANCommander.SDK/GameSaveManager.cs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/LANCommander.SDK/Client.cs b/LANCommander.SDK/Client.cs index d2996726..4d2f4b8a 100644 --- a/LANCommander.SDK/Client.cs +++ b/LANCommander.SDK/Client.cs @@ -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; } diff --git a/LANCommander.SDK/GameSaveManager.cs b/LANCommander.SDK/GameSaveManager.cs index c3ad883e..2702b75b 100644 --- a/LANCommander.SDK/GameSaveManager.cs +++ b/LANCommander.SDK/GameSaveManager.cs @@ -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;