- Fixed a rare Steam Store query issue
This commit is contained in:
pointfeev 2022-08-30 20:14:35 -04:00
parent 9bfefbd6f3
commit 207d2d4a2e
3 changed files with 73 additions and 26 deletions

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>4.1.1.0</Version> <Version>4.1.2.0</Version>
<PackageIcon>Resources\ini.ico</PackageIcon> <PackageIcon>Resources\ini.ico</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>

View file

@ -119,12 +119,11 @@ internal static class Resources
|| subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT")); || subPath.Contains("CRASH") && (subPath.Contains("PAD") || subPath.Contains("REPORT"));
} }
internal static async Task<List<string>> GetDllDirectoriesFromGameDirectory(this string gameDirectory, Platform platform, List<string> dllDirectories = null) => await Task.Run(() => internal static async Task<List<string>> GetDllDirectoriesFromGameDirectory(this string gameDirectory, Platform platform) => await Task.Run(() =>
{ {
dllDirectories ??= new(); List<string> dllDirectories = new();
if (Program.Canceled || !Directory.Exists(gameDirectory)) return null; if (Program.Canceled || !Directory.Exists(gameDirectory)) return null;
List<string> directories = new(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory }; foreach (string subDirectory in new List<string>(Directory.EnumerateDirectories(gameDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true })) { gameDirectory })
foreach (string subDirectory in directories)
{ {
if (Program.Canceled) return null; if (Program.Canceled) return null;
Thread.Sleep(0); Thread.Sleep(0);

View file

@ -46,32 +46,74 @@ internal static class SteamStore
{ {
try try
{ {
AppData data = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString()).data; AppDetails appDetails = JsonConvert.DeserializeObject<AppDetails>(app.Value.ToString());
if (data is not null) if (appDetails is not null)
{ {
try AppData data = appDetails.data;
if (!appDetails.success)
{ {
File.WriteAllText(cacheFile, JsonConvert.SerializeObject(data, Formatting.Indented));
}
catch
#if DEBUG #if DEBUG
(Exception e) Form.ActiveForm.Invoke(() =>
{ {
using DialogForm dialogForm = new(null); using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Unsuccessful serialization of query for appid " + appId + ":\n\n" + e.ToString()); dialogForm.Show(SystemIcons.Error, "Query unsuccessful for appid: " + appId + $"\nisDlc: {isDlc}\ndata is null: {data is null}\n\n" + app.Value.ToString());
} });
#else #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 #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 catch
#if DEBUG #if DEBUG
(Exception e) (Exception e)
{ {
using DialogForm dialogForm = new(null); Form.ActiveForm.Invoke(() =>
dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString()); {
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Unsuccessful deserialization of query for appid " + appId + ":\n\n" + e.ToString());
});
} }
#else #else
{ } { }
@ -81,16 +123,22 @@ internal static class SteamStore
#if DEBUG #if DEBUG
else else
{ {
using DialogForm dialogForm = new(null); Form.ActiveForm.Invoke(() =>
dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId); {
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response deserialization null for appid: " + appId);
});
} }
#endif #endif
} }
#if DEBUG #if DEBUG
else else
{ {
using DialogForm dialogForm = new(null); Form.ActiveForm.Invoke(() =>
dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId); {
using DialogForm dialogForm = new(Form.ActiveForm);
dialogForm.Show(SystemIcons.Error, "Response null for appid: " + appId);
});
} }
#endif #endif
} }
@ -108,7 +156,7 @@ internal static class SteamStore
if (!isDlc) if (!isDlc)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
return await QueryStoreAPI(appId); return await QueryStoreAPI(appId, isDlc);
} }
return null; return null;
} }