Skip to content

Commit e6e1dc7

Browse files
committed
Why tf did I request the cache from long long long ago
1 parent 7097de1 commit e6e1dc7

1 file changed

Lines changed: 36 additions & 29 deletions

File tree

Oculus Downgrader/Program.cs

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void Main(string[] args)
4949
// Handle oculus uri scheme
5050
Logger.SetLogFile(AppDomain.CurrentDomain.BaseDirectory + "Log.log");
5151
SetupExceptionHandlers();
52-
DowngradeManager.updater = new Updater("1.11.44", "https://github.com/ComputerElite/Oculus-downgrader", "Oculus Downgrader", Assembly.GetExecutingAssembly().Location);
52+
DowngradeManager.updater = new Updater("1.11.45", "https://github.com/ComputerElite/Oculus-downgrader", "Oculus Downgrader", Assembly.GetExecutingAssembly().Location);
5353
Logger.LogRaw("\n\n");
5454
Logger.Log("Starting Oculus Downgrader version " + DowngradeManager.updater.version);
5555
if (args.Length == 1 && args[0] == "--update")
@@ -1189,6 +1189,7 @@ public void StoreSearch(string autoterm = "")
11891189

11901190
Dictionary<string, string> nameIdRaw = new Dictionary<string, string>();
11911191
Dictionary<string, string> nameId = new Dictionary<string, string>();
1192+
int failed = 0;
11921193

11931194
Logger.Log("Requesting results from Oculus");
11941195
Console.WriteLine("Requesting results from Oculus");
@@ -1212,6 +1213,7 @@ public void StoreSearch(string autoterm = "")
12121213
{
12131214
Error("Couldn't get results from Oculus");
12141215
Logger.Log("Couldn't get results from Oculus: " + e);
1216+
failed += 1;
12151217
}
12161218

12171219
try
@@ -1231,12 +1233,42 @@ public void StoreSearch(string autoterm = "")
12311233
{
12321234
Error("Couldn't get results from OculusDB");
12331235
Logger.Log("Couldn't get results from OculusDB: " + e);
1236+
failed += 1;
12341237
}
1238+
1239+
if (failed >= 2)
1240+
{
1241+
Logger.Log("Requesting cache results");
1242+
WebClient client = new WebClient();
1243+
client.Headers.Add("user-agent", updater.AppName + "/" + updater.version);
1244+
List<IndexEntry> apps = JsonSerializer.Deserialize<List<IndexEntry>>(client.DownloadString("https://computerelite.github.io/tools/Oculus/OlderAppVersions/index.json"));
1245+
foreach(IndexEntry e in apps)
1246+
{
1247+
if (!e.name.ToLower().Contains(term.ToLower())) continue;
1248+
if (Enum.GetName(typeof(Headset), config.headset) != e.headset) continue;
1249+
if (nameId.ContainsKey(e.name) && nameId[e.name] == e.id) continue;
1250+
int increment = 0;
1251+
while (nameId.ContainsKey(e.name.ToLower() + (increment == 0 ? "" : " " + increment)))
1252+
{
1253+
increment++;
1254+
}
1255+
string name = e.name + (increment == 0 ? "" : " " + increment);
1256+
Logger.Log(" - " + name);
1257+
Console.WriteLine(" - " + name);
1258+
if (name.ToLower() == term.ToLower())
1259+
{
1260+
Logger.Log("Result is exact match. Auto selecting");
1261+
Console.WriteLine("Result is exact match. Auto selecting");
1262+
ShowVersions(e.id);
1263+
return;
1264+
}
1265+
nameId.Add(name.ToLower(), e.id);
1266+
}
1267+
}
1268+
12351269
Console.WriteLine();
12361270
Logger.Log("Results: ");
12371271
Console.WriteLine("Results: ");
1238-
1239-
12401272
foreach (KeyValuePair<string,string> pair in nameIdRaw)
12411273
{
12421274
int increment = 0;
@@ -1257,32 +1289,7 @@ public void StoreSearch(string autoterm = "")
12571289
return;
12581290
}
12591291
}
1260-
Logger.Log("Requesting cache results");
1261-
WebClient client = new WebClient();
1262-
client.Headers.Add("user-agent", updater.AppName + "/" + updater.version);
1263-
List<IndexEntry> apps = JsonSerializer.Deserialize<List<IndexEntry>>(client.DownloadString("https://computerelite.github.io/tools/Oculus/OlderAppVersions/index.json"));
1264-
foreach(IndexEntry e in apps)
1265-
{
1266-
if (!e.name.ToLower().Contains(term.ToLower())) continue;
1267-
if (Enum.GetName(typeof(Headset), config.headset) != e.headset) continue;
1268-
if (nameId.ContainsKey(e.name) && nameId[e.name] == e.id) continue;
1269-
int increment = 0;
1270-
while (nameId.ContainsKey(e.name.ToLower() + (increment == 0 ? "" : " " + increment)))
1271-
{
1272-
increment++;
1273-
}
1274-
string name = e.name + (increment == 0 ? "" : " " + increment);
1275-
Logger.Log(" - " + name);
1276-
Console.WriteLine(" - " + name);
1277-
if (name.ToLower() == term.ToLower())
1278-
{
1279-
Logger.Log("Result is exact match. Auto selecting");
1280-
Console.WriteLine("Result is exact match. Auto selecting");
1281-
ShowVersions(e.id);
1282-
return;
1283-
}
1284-
nameId.Add(name.ToLower(), e.id);
1285-
}
1292+
12861293
Console.WriteLine();
12871294
bool choosen = false;
12881295
string sel = "";

0 commit comments

Comments
 (0)