Skip to content

Commit a31fa2e

Browse files
committed
Add option to retry if download fails (also v1.0 woo)
1 parent fe161b6 commit a31fa2e

File tree

3 files changed

+49
-36
lines changed

3 files changed

+49
-36
lines changed

FlashpointInstaller/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
3434
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0-rc10")]
35+
[assembly: AssemblyFileVersion("1.0")]

FlashpointInstaller/src/Forms/Operate.cs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,36 @@ private async void Operation_Load(object sender, EventArgs e)
5959

6060
if (component.Size > 0)
6161
{
62-
try
62+
while (true)
6363
{
64-
stream = new MemoryStream(await client.DownloadDataTaskAsync(new Uri(component.URL)));
65-
}
66-
catch (WebException ex)
67-
{
68-
if (ex.Status != WebExceptionStatus.RequestCanceled)
64+
try
6965
{
70-
MessageBox.Show(
71-
$"The {workingComponent.Title} component failed to download.\n\n" +
72-
"If this issue persists, please let us know as soon as possible.",
73-
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error
74-
);
66+
stream = new MemoryStream(await client.DownloadDataTaskAsync(new Uri(component.URL)));
7567
}
68+
catch (WebException ex)
69+
{
70+
if (ex.Status != WebExceptionStatus.RequestCanceled)
71+
{
72+
var errorResult = MessageBox.Show(
73+
$"The {workingComponent.Title} component failed to download.\n\n" +
74+
"Click OK to retry, or Cancel to abort the installation.",
75+
"Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error
76+
);
7677

77-
cancelStatus = 2;
78-
CancelButton.PerformClick();
79-
return;
80-
}
81-
}
78+
if (errorResult == DialogResult.OK) continue;
79+
}
8280

83-
await Task.Run(ExtractComponents);
81+
cancelStatus = 2;
82+
CancelButton.PerformClick();
83+
return;
84+
}
8485

85-
byteProgress += component.Size;
86+
await Task.Run(ExtractComponents);
87+
88+
byteProgress += component.Size;
89+
break;
90+
}
91+
}
8692
}
8793

8894
if (cancelStatus == 0)

FlashpointManager/src/Forms/Operate.cs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,36 @@ private async void Operation_Load(object sender, EventArgs e)
9292

9393
if (component.Size > 0)
9494
{
95-
try
95+
while (true)
9696
{
97-
stream = new MemoryStream(await client.DownloadDataTaskAsync(new Uri(component.URL)));
98-
}
99-
catch (WebException ex)
100-
{
101-
if (ex.Status != WebExceptionStatus.RequestCanceled)
97+
try
10298
{
103-
FPM.GenericError(
104-
$"The {workingComponent.Title} component failed to download.\n\n" +
105-
"If this issue persists, please let us know as soon as possible."
106-
);
99+
stream = new MemoryStream(await client.DownloadDataTaskAsync(new Uri(component.URL)));
100+
}
101+
catch (WebException ex)
102+
{
103+
if (ex.Status != WebExceptionStatus.RequestCanceled)
104+
{
105+
var errorResult = MessageBox.Show(
106+
$"The {workingComponent.Title} component failed to download.\n\n" +
107+
"Click OK to retry, or Cancel to abort the installation.",
108+
"Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error
109+
);
110+
111+
if (errorResult == DialogResult.OK) continue;
112+
}
113+
114+
cancelStatus = 2;
115+
CancelButton.PerformClick();
116+
return;
107117
}
108118

109-
cancelStatus = 2;
110-
CancelButton.PerformClick();
111-
return;
119+
await Task.Run(ExtractComponents);
120+
121+
byteProgress += component.Size;
122+
break;
112123
}
113124
}
114-
115-
await Task.Run(ExtractComponents);
116-
117-
byteProgress += component.Size;
118125
}
119126

120127
if (cancelStatus != 0) return;

0 commit comments

Comments
 (0)