From c3a5edbe46d395513def332f4293b1fc9f45f54a Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Tue, 28 Nov 2023 21:20:07 -0600 Subject: [PATCH] Update SharpCompress to latest version and rework cancellation --- .../LANCommander.PlaynitePlugin.csproj | 4 +- .../packages.config | 2 +- LANCommander.SDK/GameManager.cs | 41 +++++++++---------- LANCommander.SDK/LANCommander.SDK.csproj | 2 +- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/LANCommander.Playnite.Extension/LANCommander.PlaynitePlugin.csproj b/LANCommander.Playnite.Extension/LANCommander.PlaynitePlugin.csproj index 1e0bcf3..81642af 100644 --- a/LANCommander.Playnite.Extension/LANCommander.PlaynitePlugin.csproj +++ b/LANCommander.Playnite.Extension/LANCommander.PlaynitePlugin.csproj @@ -52,8 +52,8 @@ ..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll - - ..\packages\SharpCompress.0.34.1\lib\net462\SharpCompress.dll + + ..\packages\SharpCompress.0.34.2\lib\net462\SharpCompress.dll diff --git a/LANCommander.Playnite.Extension/packages.config b/LANCommander.Playnite.Extension/packages.config index ccd536f..900ade3 100644 --- a/LANCommander.Playnite.Extension/packages.config +++ b/LANCommander.Playnite.Extension/packages.config @@ -8,7 +8,7 @@ - + diff --git a/LANCommander.SDK/GameManager.cs b/LANCommander.SDK/GameManager.cs index 7600d62..634cde1 100644 --- a/LANCommander.SDK/GameManager.cs +++ b/LANCommander.SDK/GameManager.cs @@ -179,34 +179,31 @@ namespace LANCommander.SDK Reader.Dispose(); Stream.Dispose(); } + catch (ReaderCancelledException ex) + { + Logger?.LogTrace("User cancelled the download"); + + extractionResult.Canceled = true; + + if (Directory.Exists(destination)) + { + Logger?.LogTrace("Cleaning up orphaned files after cancelled install"); + + Directory.Delete(destination, true); + } + } catch (Exception ex) { - if (Reader.Cancelled) + Logger?.LogError(ex, "Could not extract to path {Destination}", destination); + + if (Directory.Exists(destination)) { - Logger?.LogTrace("User cancelled the download"); + Logger?.LogTrace("Cleaning up orphaned install files after bad install"); - extractionResult.Canceled = true; - - if (Directory.Exists(destination)) - { - Logger?.LogTrace("Cleaning up orphaned files after cancelled install"); - - Directory.Delete(destination, true); - } + Directory.Delete(destination, true); } - else - { - Logger?.LogError(ex, "Could not extract to path {Destination}", destination); - if (Directory.Exists(destination)) - { - Logger?.LogTrace("Cleaning up orphaned install files after bad install"); - - Directory.Delete(destination, true); - } - - throw new Exception("The game archive could not be extracted, is it corrupted? Please try again"); - } + throw new Exception("The game archive could not be extracted, is it corrupted? Please try again"); } if (!extractionResult.Canceled) diff --git a/LANCommander.SDK/LANCommander.SDK.csproj b/LANCommander.SDK/LANCommander.SDK.csproj index 2e097cf..ba884b6 100644 --- a/LANCommander.SDK/LANCommander.SDK.csproj +++ b/LANCommander.SDK/LANCommander.SDK.csproj @@ -8,7 +8,7 @@ - +