fix branch detection
This commit is contained in:
parent
2d773481cc
commit
eec1e9821d
3 changed files with 91 additions and 57 deletions
|
@ -190,12 +190,18 @@ internal static class SteamCMD
|
||||||
|
|
||||||
internal static async Task<VProperty> GetAppInfo(string appId, string branch = "public", int buildId = 0)
|
internal static async Task<VProperty> GetAppInfo(string appId, string branch = "public", int buildId = 0)
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
int attempts = 0;
|
||||||
return null;
|
while (!Program.Canceled)
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
if (attempts > 10)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
DebugForm.Current.Log("Failed to query SteamCMD after 10 tries: " + appId + " (" + branch + ")", LogTextBox.Warning);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
string appUpdateFile = $@"{AppInfoPath}\{appId}.vdf";
|
string appUpdateFile = $@"{AppInfoPath}\{appId}.vdf";
|
||||||
restart:
|
|
||||||
if (Program.Canceled)
|
|
||||||
return null;
|
|
||||||
string output = appUpdateFile.ReadFile();
|
string output = appUpdateFile.ReadFile();
|
||||||
if (output is null)
|
if (output is null)
|
||||||
{
|
{
|
||||||
|
@ -209,14 +215,22 @@ internal static class SteamCMD
|
||||||
appUpdateFile.WriteFile(output);
|
appUpdateFile.WriteFile(output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto restart;
|
{
|
||||||
|
#if DEBUG
|
||||||
|
DebugForm.Current.Log("SteamCMD query failed on attempt #" + attempts + " for " + appId + " (" + branch + "): Bad output",
|
||||||
|
LogTextBox.Warning);
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Program.Canceled)
|
|
||||||
return null;
|
|
||||||
if (!ValveDataFile.TryDeserialize(output, out VProperty appInfo) || appInfo.Value is VValue)
|
if (!ValveDataFile.TryDeserialize(output, out VProperty appInfo) || appInfo.Value is VValue)
|
||||||
{
|
{
|
||||||
appUpdateFile.DeleteFile();
|
appUpdateFile.DeleteFile();
|
||||||
goto restart;
|
#if DEBUG
|
||||||
|
DebugForm.Current.Log("SteamCMD query failed on attempt #" + attempts + " for " + appId + " (" + branch + "): Deserialization failed",
|
||||||
|
LogTextBox.Warning);
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (appInfo.Value.Children().ToList().Count == 0)
|
if (appInfo.Value.Children().ToList().Count == 0)
|
||||||
return appInfo;
|
return appInfo;
|
||||||
|
@ -232,7 +246,11 @@ internal static class SteamCMD
|
||||||
foreach (string dlcAppUpdateFile in dlcAppIds.Select(id => $@"{AppInfoPath}\{id}.vdf"))
|
foreach (string dlcAppUpdateFile in dlcAppIds.Select(id => $@"{AppInfoPath}\{id}.vdf"))
|
||||||
dlcAppUpdateFile.DeleteFile();
|
dlcAppUpdateFile.DeleteFile();
|
||||||
appUpdateFile.DeleteFile();
|
appUpdateFile.DeleteFile();
|
||||||
goto restart;
|
#if DEBUG
|
||||||
|
DebugForm.Current.Log("SteamCMD query skipped on attempt #" + attempts + " for " + appId + " (" + branch + "): Outdated cache", LogTextBox.Warning);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<List<string>> ParseDlcAppIds(VProperty appInfo)
|
internal static async Task<List<string>> ParseDlcAppIds(VProperty appInfo)
|
||||||
|
|
|
@ -69,7 +69,15 @@ internal static class SteamLibrary
|
||||||
continue;
|
continue;
|
||||||
if (!int.TryParse(buildId, out int buildIdInt))
|
if (!int.TryParse(buildId, out int buildIdInt))
|
||||||
continue;
|
continue;
|
||||||
string branch = result.Value.GetChild("UserConfig")?.GetChild("betakey")?.ToString();
|
VToken userConfig = result.Value.GetChild("UserConfig");
|
||||||
|
string branch = userConfig?.GetChild("BetaKey")?.ToString();
|
||||||
|
branch ??= userConfig?.GetChild("betakey")?.ToString();
|
||||||
|
if (branch is null)
|
||||||
|
{
|
||||||
|
VToken mountedConfig = result.Value.GetChild("MountedConfig");
|
||||||
|
branch = mountedConfig?.GetChild("BetaKey")?.ToString();
|
||||||
|
branch ??= mountedConfig?.GetChild("betakey")?.ToString();
|
||||||
|
}
|
||||||
if (string.IsNullOrWhiteSpace(branch))
|
if (string.IsNullOrWhiteSpace(branch))
|
||||||
branch = "public";
|
branch = "public";
|
||||||
games.Add((appId, name, branch, buildIdInt, gameDirectory));
|
games.Add((appId, name, branch, buildIdInt, gameDirectory));
|
||||||
|
|
|
@ -30,10 +30,9 @@ internal static class SteamStore
|
||||||
|
|
||||||
internal static async Task<AppData> QueryStoreAPI(string appId, bool isDlc = false, int attempts = 0)
|
internal static async Task<AppData> QueryStoreAPI(string appId, bool isDlc = false, int attempts = 0)
|
||||||
{
|
{
|
||||||
while (true)
|
while (!Program.Canceled)
|
||||||
{
|
{
|
||||||
if (Program.Canceled)
|
attempts++;
|
||||||
return null;
|
|
||||||
string cacheFile = ProgramData.AppInfoPath + @$"\{appId}.json";
|
string cacheFile = ProgramData.AppInfoPath + @$"\{appId}.json";
|
||||||
bool cachedExists = cacheFile.FileExists();
|
bool cachedExists = cacheFile.FileExists();
|
||||||
if (!cachedExists || ProgramData.CheckCooldown(appId, isDlc ? CooldownDlc : CooldownGame))
|
if (!cachedExists || ProgramData.CheckCooldown(appId, isDlc ? CooldownDlc : CooldownGame))
|
||||||
|
@ -54,8 +53,8 @@ internal static class SteamStore
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
DebugForm.Current.Log(
|
DebugForm.Current.Log(
|
||||||
$"Query unsuccessful for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}",
|
"Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
LogTextBox.Warning);
|
+ ": Query unsuccessful (" + app.Value.ToString(Formatting.None) + ")", LogTextBox.Warning);
|
||||||
#endif
|
#endif
|
||||||
if (data is null)
|
if (data is null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -70,8 +69,8 @@ internal static class SteamStore
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
(Exception e)
|
(Exception e)
|
||||||
{
|
{
|
||||||
DebugForm.Current.Log(
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
$"Unsuccessful serialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
|
+ ": Unsuccessful serialization (" + e.Message + ")");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
@ -81,22 +80,22 @@ internal static class SteamStore
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
DebugForm.Current.Log(
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
$"Response data null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
|
+ ": Response data null (" + app.Value.ToString(Formatting.None) + ")");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
else
|
else
|
||||||
DebugForm.Current.Log(
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
$"Response details null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
|
+ ": Response details null (" + app.Value.ToString(Formatting.None) + ")");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
(Exception e)
|
(Exception e)
|
||||||
{
|
{
|
||||||
DebugForm.Current.Log(
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
$"Unsuccessful deserialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
|
+ ": Unsuccessful deserialization (" + e.Message + ")");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
@ -105,13 +104,15 @@ internal static class SteamStore
|
||||||
#endif
|
#endif
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
else
|
else
|
||||||
DebugForm.Current.Log("Response deserialization null for appid " + appId);
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||||
|
+ ": Response deserialization null");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
DebugForm.Current.Log("Response null for appid " + appId, LogTextBox.Warning);
|
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "") + ": Response null",
|
||||||
|
LogTextBox.Warning);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,10 +125,17 @@ internal static class SteamStore
|
||||||
{
|
{
|
||||||
cacheFile.DeleteFile();
|
cacheFile.DeleteFile();
|
||||||
}
|
}
|
||||||
if (isDlc || attempts >= 10)
|
if (isDlc)
|
||||||
return null;
|
break;
|
||||||
Thread.Sleep(1000);
|
if (attempts > 10)
|
||||||
attempts = ++attempts;
|
{
|
||||||
|
#if DEBUG
|
||||||
|
DebugForm.Current.Log("Failed to query Steam store after 10 tries: " + appId);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue