From 207d2d4a2e1cd28c29d70b0dab783aba3a1d02cf Mon Sep 17 00:00:00 2001 From: pointfeev Date: Tue, 30 Aug 2022 20:14:35 -0400 Subject: [PATCH] v4.1.2.0 - Fixed a rare Steam Store query issue --- CreamInstaller/CreamInstaller.csproj | 2 +- CreamInstaller/Resources/Resources.cs | 7 +-- CreamInstaller/Steam/SteamStore.cs | 90 ++++++++++++++++++++------- 3 files changed, 73 insertions(+), 26 deletions(-) diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 8e2b866..97dc9f3 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 4.1.1.0 + 4.1.2.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index eb2c5bd..0c5197c 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -119,12 +119,11 @@ internal static class Resources || subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT")); } - internal static async Task> GetDllDirectoriesFromGameDirectory(this string gameDirectory, Platform platform, List dllDirectories = null) => await Task.Run(() => + internal static async Task> GetDllDirectoriesFromGameDirectory(this string gameDirectory, Platform platform) => await Task.Run(() => { - dllDirectories ??= new(); + List dllDirectories = new(); if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; - List directories = new(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory }; - foreach (string subDirectory in directories) + foreach (string subDirectory in new List(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory }) { if (Program.Canceled) return null; Thread.Sleep(0); diff --git a/CreamInstaller/Steam/SteamStore.cs b/CreamInstaller/Steam/SteamStore.cs index 5d559c4..7a89d8e 100644 --- a/CreamInstaller/Steam/SteamStore.cs +++ b/CreamInstaller/Steam/SteamStore.cs @@ -46,32 +46,74 @@ internal static class SteamStore { try { - AppData data = JsonConvert.DeserializeObject(app.Value.ToString()).data; - if (data is not null) + AppDetails appDetails = JsonConvert.DeserializeObject(app.Value.ToString()); + if (appDetails is not null) { - try + AppData data = appDetails.data; + if (!appDetails.success) { - File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented)); - } - catch #if DEBUG - (Exception e) - { - using DialogForm dialogForm = new(null); - dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString()); - } -#else - { } + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Query unsuccessful for appid: " + appId + $"\nisDlc: {isDlc}\ndata is null: {data is null}\n\n" + app.Value.ToString()); + }); +#endif + if (data is null) + return null; + } + if (data is not null) + { + try + { + File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented)); + } + catch +#if DEBUG + (Exception e) + { + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString()); + }); + } +#else + { } +#endif + return data; + } +#if DEBUG + else + { + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Response data null for appid: " + appId + "\n\n" + app.Value.ToString()); + }); + } #endif - return data; } +#if DEBUG + else + { + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Response details null for appid: " + appId + "\n\n" + app.Value.ToString()); + }); + } +#endif } catch #if DEBUG (Exception e) { - using DialogForm dialogForm = new(null); - dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString()); + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString()); + }); } #else { } @@ -81,16 +123,22 @@ internal static class SteamStore #if DEBUG else { - using DialogForm dialogForm = new(null); - dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId); + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId); + }); } #endif } #if DEBUG else { - using DialogForm dialogForm = new(null); - dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId); + Form.ActiveForm.Invoke(() => + { + using DialogForm dialogForm = new(Form.ActiveForm); + dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId); + }); } #endif } @@ -108,7 +156,7 @@ internal static class SteamStore if (!isDlc) { Thread.Sleep(1000); - return await QueryStoreAPI(appId); + return await QueryStoreAPI(appId, isDlc); } return null; }