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)
|
||||
{
|
||||
if (Program.Canceled)
|
||||
return null;
|
||||
int attempts = 0;
|
||||
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";
|
||||
restart:
|
||||
if (Program.Canceled)
|
||||
return null;
|
||||
string output = appUpdateFile.ReadFile();
|
||||
if (output is null)
|
||||
{
|
||||
|
@ -209,14 +215,22 @@ internal static class SteamCMD
|
|||
appUpdateFile.WriteFile(output);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return appInfo;
|
||||
|
@ -232,7 +246,11 @@ internal static class SteamCMD
|
|||
foreach (string dlcAppUpdateFile in dlcAppIds.Select(id => $@"{AppInfoPath}\{id}.vdf"))
|
||||
dlcAppUpdateFile.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)
|
||||
|
|
|
@ -69,7 +69,15 @@ internal static class SteamLibrary
|
|||
continue;
|
||||
if (!int.TryParse(buildId, out int buildIdInt))
|
||||
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))
|
||||
branch = "public";
|
||||
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)
|
||||
{
|
||||
while (true)
|
||||
while (!Program.Canceled)
|
||||
{
|
||||
if (Program.Canceled)
|
||||
return null;
|
||||
attempts++;
|
||||
string cacheFile = ProgramData.AppInfoPath + @$"\{appId}.json";
|
||||
bool cachedExists = cacheFile.FileExists();
|
||||
if (!cachedExists || ProgramData.CheckCooldown(appId, isDlc ? CooldownDlc : CooldownGame))
|
||||
|
@ -54,8 +53,8 @@ internal static class SteamStore
|
|||
{
|
||||
#if DEBUG
|
||||
DebugForm.Current.Log(
|
||||
$"Query unsuccessful for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}",
|
||||
LogTextBox.Warning);
|
||||
"Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||
+ ": Query unsuccessful (" + app.Value.ToString(Formatting.None) + ")", LogTextBox.Warning);
|
||||
#endif
|
||||
if (data is null)
|
||||
return null;
|
||||
|
@ -70,8 +69,8 @@ internal static class SteamStore
|
|||
#if DEBUG
|
||||
(Exception e)
|
||||
{
|
||||
DebugForm.Current.Log(
|
||||
$"Unsuccessful serialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
|
||||
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||
+ ": Unsuccessful serialization (" + e.Message + ")");
|
||||
}
|
||||
#else
|
||||
{
|
||||
|
@ -81,22 +80,22 @@ internal static class SteamStore
|
|||
return data;
|
||||
}
|
||||
#if DEBUG
|
||||
DebugForm.Current.Log(
|
||||
$"Response data null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
|
||||
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||
+ ": Response data null (" + app.Value.ToString(Formatting.None) + ")");
|
||||
#endif
|
||||
}
|
||||
#if DEBUG
|
||||
else
|
||||
DebugForm.Current.Log(
|
||||
$"Response details null for appid {appId}{(isDlc ? " (DLC)" : "")}: {app.Value.ToString(Formatting.None)}");
|
||||
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||
+ ": Response details null (" + app.Value.ToString(Formatting.None) + ")");
|
||||
#endif
|
||||
}
|
||||
catch
|
||||
#if DEBUG
|
||||
(Exception e)
|
||||
{
|
||||
DebugForm.Current.Log(
|
||||
$"Unsuccessful deserialization of query for appid {appId}{(isDlc ? " (DLC)" : "")}: {e.GetType()} ({e.Message})");
|
||||
DebugForm.Current.Log("Steam store query failed on attempt #" + attempts + " for " + appId + (isDlc ? " (DLC)" : "")
|
||||
+ ": Unsuccessful deserialization (" + e.Message + ")");
|
||||
}
|
||||
#else
|
||||
{
|
||||
|
@ -105,13 +104,15 @@ internal static class SteamStore
|
|||
#endif
|
||||
#if DEBUG
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
@ -124,10 +125,17 @@ internal static class SteamStore
|
|||
{
|
||||
cacheFile.DeleteFile();
|
||||
}
|
||||
if (isDlc || attempts >= 10)
|
||||
return null;
|
||||
if (isDlc)
|
||||
break;
|
||||
if (attempts > 10)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugForm.Current.Log("Failed to query Steam store after 10 tries: " + appId);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
attempts = ++attempts;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue