From 11376bbdf79f23c74679f77ac46f242d072a09ac Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sat, 29 May 2021 21:11:06 +1200 Subject: [PATCH] Try fix crash when canceling download --- AssetBundleCacher.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/AssetBundleCacher.cs b/AssetBundleCacher.cs index eee01484..7245c9ec 100644 --- a/AssetBundleCacher.cs +++ b/AssetBundleCacher.cs @@ -159,17 +159,24 @@ namespace VRCX public void CancelDownload() { DownloadCanceled = true; - if (client != null) + try { - client.CancelAsync(); + if (client != null) + { + client.CancelAsync(); } if (process != null && !process.HasExited) { process.Kill(); if (File.Exists(DownloadTempLocation)) - File.Delete(DownloadTempLocation); - if (Directory.Exists(Path.Combine(AssetBundleCacherTemp, AssetId))) - Directory.Delete(Path.Combine(AssetBundleCacherTemp, AssetId), true); + File.Delete(DownloadTempLocation); + if (Directory.Exists(Path.Combine(AssetBundleCacherTemp, AssetId))) + Directory.Delete(Path.Combine(AssetBundleCacherTemp, AssetId), true); + } + } + catch(Exception) + { + } DownloadProgress = -4; } @@ -256,7 +263,7 @@ namespace VRCX Directory.Delete(Path.Combine(AssetBundleCacherTemp, AssetId), true); File.Delete(DownloadTempLocation); } - catch + catch(Exception) { DownloadProgress = -14; return;