From 1b231ddf0d65bf6c1c6e291c84830512513446d8 Mon Sep 17 00:00:00 2001 From: SirMangler Date: Mon, 21 Sep 2020 04:10:04 +0100 Subject: [PATCH] [BuildList] Fix downloading builds with new download url --- DolphinBisectTool/Backend.cs | 27 ++++++++++++++------------- DolphinBisectTool/MainWindow.cs | 11 ++++++----- DolphinBisectTool/ProcessBuildList.cs | 18 ++++++++++++++++-- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/DolphinBisectTool/Backend.cs b/DolphinBisectTool/Backend.cs index a9838ef..31b33f7 100644 --- a/DolphinBisectTool/Backend.cs +++ b/DolphinBisectTool/Backend.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Net; using System.Windows.Forms; using SevenZip; @@ -28,9 +29,9 @@ class Backend int m_first_index; int m_second_index; - List m_build_list; + readonly Dictionary m_build_list; - public Backend(int first_index, int second_index, List build_list) + public Backend(int first_index, int second_index, Dictionary build_list) { m_first_index = first_index; m_second_index = second_index; @@ -39,7 +40,6 @@ public Backend(int first_index, int second_index, List build_list) public void Bisect(string boot_title = "") { - string base_url = "https://dl.dolphin-emu.org/builds/dolphin-master-"; int test_index = 0; int test_direction = 0; List skipped_builds = new List(); @@ -50,20 +50,21 @@ public void Bisect(string boot_title = "") { test_index = m_first_index == -1 ? (0 + m_second_index) / 2 : (m_first_index + m_second_index) / 2; - + string download_url = m_build_list.ElementAt(test_index).Value; + string download_revison = m_build_list.ElementAt(test_index).Key; // dumb thing to make sure we keep trying to download a build until we get a valid build do { try { - Download(base_url + m_build_list[test_index] + "-x64.7z", m_build_list[test_index]); - log.Write("Testing build " + m_build_list[test_index]); + Download(download_url); + log.Write("Testing build " + download_revison); break; } catch (Exception e) { - log.Write("ERROR. Skipping build " + m_build_list[test_index]); - skipped_builds.Add(m_build_list[test_index]); + log.Write("ERROR. Skipping build " + download_revison); + skipped_builds.Add(download_revison); BisectError(e.Message); if (test_direction == 0) --test_index; @@ -82,13 +83,13 @@ public void Bisect(string boot_title = "") if (return_val == UserInput.Yes) { - log.Write("Build " + m_build_list[test_index] + " marked as a BAD build"); + log.Write("Build " + download_revison + " marked as a BAD build"); m_first_index = test_index; test_direction = 1; } else if (return_val == UserInput.No) { - log.Write("Build " + m_build_list[test_index] + " marked as a GOOD build"); + log.Write("Build " + download_revison + " marked as a GOOD build"); m_second_index = test_index; test_direction = 0; } @@ -96,7 +97,7 @@ public void Bisect(string boot_title = "") return; } - log.Write("Bisect completed. " + m_build_list[test_index] + " may be the culprit."); + log.Write("Bisect completed. " + m_build_list.ElementAt(test_index).Key + " may be the culprit."); if (!(skipped_builds.Count == 0)) { string sb = string.Join(", ", skipped_builds.ToArray()); @@ -107,11 +108,11 @@ public void Bisect(string boot_title = "") if (open_url == UserInput.Yes) { - Process.Start("https://dolp.in/" + m_build_list[test_index-1]); + Process.Start("https://dolp.in/" + m_build_list.ElementAt(test_index - 1).Key); } } - public void Download(string url, string version) + public void Download(string url) { // Windows will throw an error if you have the folder you're trying to delete open in // explorer. It will remove the contents but error out on the folder removal. That's diff --git a/DolphinBisectTool/MainWindow.cs b/DolphinBisectTool/MainWindow.cs index 3be99c4..4308636 100644 --- a/DolphinBisectTool/MainWindow.cs +++ b/DolphinBisectTool/MainWindow.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; namespace DolphinBisectTool @@ -7,7 +8,7 @@ namespace DolphinBisectTool public partial class MainWindow : Form { - List m_build_list; + Dictionary m_build_list; static string s_major_version = "5.0"; DownloadBuildList m_download_build_list = new DownloadBuildList(); @@ -30,12 +31,12 @@ private UserInput BisectUserDialog(int build, bool final_trigger) DialogResult result; if (!final_trigger) { - result = MessageBox.Show("Tested build " + m_build_list[build] + ". Did the bug happen in this build?", + result = MessageBox.Show("Tested build " + m_build_list.ElementAt(build).Key + ". Did the bug happen in this build?", "Bisect", MessageBoxButtons.YesNoCancel); } else { - result = MessageBox.Show("Build " + m_build_list[build-1] + " may be the cause of your issue. " + + result = MessageBox.Show("Build " + m_build_list.ElementAt(build-1).Key + " may be the cause of your issue. " + "Do you want to open the URL for that build?", "Notice", MessageBoxButtons.YesNo); start_button.Enabled = true; @@ -111,8 +112,8 @@ public void ChangeProgressBar(int value, string text, ProgressBarStyle style) download_label.Text = text; download_bar.Style = style; ProcessBuildList process_build = new ProcessBuildList(); - m_build_list = process_build.Run(s_major_version); - PopulateComboBoxes(m_build_list); + m_build_list = process_build.Run(); + PopulateComboBoxes(m_build_list.Keys.ToList()); } else { diff --git a/DolphinBisectTool/ProcessBuildList.cs b/DolphinBisectTool/ProcessBuildList.cs index c9d78ed..c639be2 100644 --- a/DolphinBisectTool/ProcessBuildList.cs +++ b/DolphinBisectTool/ProcessBuildList.cs @@ -7,14 +7,28 @@ namespace DolphinBisectTool { class ProcessBuildList { - public List Run(string s_major_version) + public Dictionary Run() { using (StreamReader reader = new StreamReader("buildindex")) { string raw_data = reader.ReadLine(); string refined_data = raw_data.Replace("\"", "").Replace("[", "").Replace("]", "").Replace(" ", ""); - List result = refined_data.Split(',').ToList(); + Dictionary result = new Dictionary(); + string[] items = refined_data.Split(','); + + for (int i = 0; i < items.Length; i += 2) + { + // A key without a value *should* be impossible, however this prevents a crash. + if (i + 2 > items.Length) + continue; + + if (result.ContainsKey(items[i])) + continue; // There are two version 4.0-390s. + + result.Add(items[i], items[i + 1]); + } + return result; } }