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

Commit d41d25e

Browse files
committed
[Backend] Add logic to deal with missing builds.
1 parent 39cbf2c commit d41d25e

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

DolphinBisectTool/Backend.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class Backend
2020
internal delegate UserInput BisectEventDelegate(int build, bool final_trigger = false);
2121
internal event BisectEventDelegate BisectEvent;
2222

23+
internal delegate void BisectErrorDelegate(string e);
24+
internal event BisectErrorDelegate BisectError;
25+
2326
internal delegate void UpdateProgressDelegate(int progress_percentage, string ui_text, ProgressBarStyle progress_type);
2427
internal event UpdateProgressDelegate UpdateProgress;
2528

@@ -38,14 +41,32 @@ public void Bisect(string boot_title = "")
3841
{
3942
string base_url = "https://dl.dolphin-emu.org/builds/dolphin-master-";
4043
int test_index = 0;
44+
int test_direction = 0;
4145
RunBuild run_build = new RunBuild();
4246

4347
while (!(m_first_index == m_second_index-1))
4448
{
4549

4650
test_index = m_first_index == -1 ? (0 + m_second_index) / 2 : (m_first_index + m_second_index) / 2;
4751

48-
Download(base_url + m_build_list[test_index] + "-x64.7z", m_build_list[test_index]);
52+
// dumb thing to make sure we keep trying to download a build until we get a valid build
53+
do
54+
{
55+
try
56+
{
57+
Download(base_url + m_build_list[test_index] + "-x64.7z", m_build_list[test_index]);
58+
break;
59+
}
60+
catch (Exception e)
61+
{
62+
BisectError(e.Message);
63+
if (test_direction == 0)
64+
--test_index;
65+
else
66+
++test_index;
67+
}
68+
}
69+
while (true);
4970

5071
if (!string.IsNullOrEmpty(boot_title))
5172
run_build.Run(boot_title);
@@ -55,9 +76,15 @@ public void Bisect(string boot_title = "")
5576
UserInput return_val = BisectEvent(test_index);
5677

5778
if (return_val == UserInput.Yes)
79+
{
5880
m_first_index = test_index;
81+
test_direction = 1;
82+
}
5983
else if (return_val == UserInput.No)
84+
{
6085
m_second_index = test_index;
86+
test_direction = 0;
87+
}
6188
else
6289
return;
6390
}
@@ -103,7 +130,15 @@ public void Download(string url, string version)
103130
{
104131
UpdateProgress(eventArgs.PercentDone, "Extracting and launching", ProgressBarStyle.Continuous);
105132
};
106-
dolphin_zip.ExtractArchive("dolphin");
133+
134+
try
135+
{
136+
dolphin_zip.ExtractArchive("dolphin");
137+
}
138+
catch (Exception e)
139+
{
140+
throw new Exception("Error extracting. Probably a missing build. Skipping this build.", e);
141+
}
107142
}
108143
}
109144
}

DolphinBisectTool/MainWindow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ private UserInput BisectUserDialog(int build, bool final_trigger)
5656
}
5757
}
5858

59+
private void BisectErrorDialog(string e)
60+
{
61+
MessageBox.Show(e);
62+
}
63+
5964
private void browse_button_Click(object sender, EventArgs e)
6065
{
6166
OpenFileDialog dialog = new OpenFileDialog();
@@ -82,6 +87,7 @@ private void start_button_Click(object sender, EventArgs e)
8287
Backend backend = new Backend(first_dev_build.SelectedIndex, second_dev_build.SelectedIndex, m_build_list);
8388
backend.BisectEvent += BisectUserDialog;
8489
backend.UpdateProgress += ChangeProgressBar;
90+
backend.BisectError += BisectErrorDialog;
8591

8692
if (boot_title.Checked)
8793
backend.Bisect(file_path_textbox.Text);

0 commit comments

Comments
 (0)