Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

BuildList: Fix downloading builds with new download url [Do not merge] #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions DolphinBisectTool/Backend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,9 +29,9 @@ class Backend

int m_first_index;
int m_second_index;
List<string> m_build_list;
readonly Dictionary<string, string> m_build_list;

public Backend(int first_index, int second_index, List<string> build_list)
public Backend(int first_index, int second_index, Dictionary<string, string> build_list)
{
m_first_index = first_index;
m_second_index = second_index;
Expand All @@ -39,7 +40,6 @@ public Backend(int first_index, int second_index, List<string> 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<String> skipped_builds = new List<string>();
Expand All @@ -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;
Expand All @@ -82,21 +83,21 @@ 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;
}
else
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());
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions DolphinBisectTool/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace DolphinBisectTool
{
public partial class MainWindow : Form
{

List<string> m_build_list;
Dictionary<string, string> m_build_list;
static string s_major_version = "5.0";

DownloadBuildList m_download_build_list = new DownloadBuildList();
Expand All @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down
18 changes: 16 additions & 2 deletions DolphinBisectTool/ProcessBuildList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,28 @@ namespace DolphinBisectTool
{
class ProcessBuildList
{
public List<string> Run(string s_major_version)
public Dictionary<string, string> Run()
{
using (StreamReader reader = new StreamReader("buildindex"))
{
string raw_data = reader.ReadLine();
string refined_data = raw_data.Replace("\"", "").Replace("[", "").Replace("]", "").Replace(" ", "");

List<string> result = refined_data.Split(',').ToList();
Dictionary<string, string> result = new Dictionary<string, string>();
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;
}
}
Expand Down