From b414c33312faa26a0c3af70fc4bddc0c8d138a38 Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Sat, 6 Jul 2019 00:14:31 -0400 Subject: [PATCH] should fix #2 --- BandagedBD/FormMain.cs | 3 +- BandagedBD/Panels/InstallPanel.cs | 32 +++++++++++++-------- BandagedBD/Properties/AssemblyInfo.cs | 8 +++--- BandagedBD/Properties/Resources.Designer.cs | 2 +- BandagedBD/Properties/Resources.resx | 16 +++++------ BandagedBD/Utilities.cs | 9 ++++++ 6 files changed, 44 insertions(+), 26 deletions(-) diff --git a/BandagedBD/FormMain.cs b/BandagedBD/FormMain.cs index b41e807..de2690f 100644 --- a/BandagedBD/FormMain.cs +++ b/BandagedBD/FormMain.cs @@ -18,6 +18,7 @@ namespace BandagedBD { public FormMain() { InitializeComponent(); + this.Text = "BandagedBD Installer v" + Properties.Resources.Version; logo.Click += Logo_Click; panelMap[PanelTypes.License] = new LicensePanel(); @@ -94,7 +95,7 @@ namespace BandagedBD { } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - Utilities.OpenProcess("https://www.paypal.me/ZackRauen"); + Utilities.OpenProcess("https://paypal.me/ZackRauen"); } } } diff --git a/BandagedBD/Panels/InstallPanel.cs b/BandagedBD/Panels/InstallPanel.cs index bb0fd44..1007d9f 100644 --- a/BandagedBD/Panels/InstallPanel.cs +++ b/BandagedBD/Panels/InstallPanel.cs @@ -47,8 +47,12 @@ namespace BandagedBD.Panels { Append($"Killing {processNames[i]} Processes"); string currentExecutable = Utilities.KillProcess(processNames[i], Append); - - if (await DownloadBd(paths[i]) != 1) return 0; + if (await DownloadBd(paths[i]) != 1) { + setProgress(0); + Append("Download seems to have failed, will try once more."); + if (await DownloadBd(paths[i]) != 1) return 0; + } + setProgress(75); if (Verify(paths[i]) != 1) return 0; setProgress(90); @@ -72,7 +76,7 @@ namespace BandagedBD.Panels { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; - using (var wc = new WebClient { Headers = this.Headers }) { + using (var wc = new TimedWebClient { Headers = this.Headers }) { wc.DownloadProgressChanged += (sender, args) => { setProgress(args.ProgressPercentage / 2); }; @@ -80,18 +84,22 @@ namespace BandagedBD.Panels { Append($"Using channel: {channel}", true); Append($"Downloading to: {dest}", true); - await wc.DownloadFileTaskAsync(channel, dest); + try { + await wc.DownloadFileTaskAsync(channel, dest); + } + catch (WebException e) { + Append("Download error: " + e.Message, true); + return 0; + } } Append("Finished downloading BandagedBD package"); - ExtractBd(dest, $"{installationPath}\\resources"); - - return 1; + return ExtractBd(dest, $"{installationPath}\\resources"); } - private void ExtractBd(string path, string dest) { + private int ExtractBd(string path, string dest) { if (Directory.Exists($"{dest}\\app")) { Append("Deleting old BetterDiscord"); @@ -107,8 +115,7 @@ namespace BandagedBD.Panels { if (!File.Exists(path)) { Append($"BandagedBD package does not exist in: {path}. Cannot continue."); - Window.Fail(); - return; + return 0; } var zar = ZipFile.OpenRead(path); @@ -121,8 +128,7 @@ namespace BandagedBD.Panels { zar.Dispose(); if (!Directory.Exists($"{dest}\\BetterDiscordApp-{branch}")) { Append($"BandagedBD package does not exist in: {dest}\\BetterDiscordApp-{branch}. Cannot continue."); - Window.Fail(); - return; + return 0; } Append("Renaming package dir"); @@ -133,6 +139,8 @@ namespace BandagedBD.Panels { Append($"Deleting temp file {path}"); File.Delete(path); } + + return 1; } private int Verify(string installationPath) { diff --git a/BandagedBD/Properties/AssemblyInfo.cs b/BandagedBD/Properties/AssemblyInfo.cs index e476b4c..00e9c70 100644 --- a/BandagedBD/Properties/AssemblyInfo.cs +++ b/BandagedBD/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("BandagedBD")] -[assembly: AssemblyDescription("BetterDiscord Windows Installer")] +[assembly: AssemblyDescription("BandagedBD Windows Installer")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Zerebos")] [assembly: AssemblyProduct("BandagedBD")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCopyright("Copyright © 2017-present")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.0.0")] -[assembly: AssemblyFileVersion("0.3.0.0")] +[assembly: AssemblyVersion("1.0.1")] +[assembly: AssemblyFileVersion("1.0.1")] diff --git a/BandagedBD/Properties/Resources.Designer.cs b/BandagedBD/Properties/Resources.Designer.cs index 54bd14c..7a4b64b 100644 --- a/BandagedBD/Properties/Resources.Designer.cs +++ b/BandagedBD/Properties/Resources.Designer.cs @@ -114,7 +114,7 @@ namespace BandagedBD.Properties { } /// - /// Looks up a localized string similar to 0.3.2. + /// Looks up a localized string similar to 1.0.1. /// internal static string Version { get { diff --git a/BandagedBD/Properties/Resources.resx b/BandagedBD/Properties/Resources.resx index 60b1281..d2f096d 100644 --- a/BandagedBD/Properties/Resources.resx +++ b/BandagedBD/Properties/Resources.resx @@ -133,8 +133,8 @@ n19RsKnwXbF2SVbpqrI3FfqVJVW7ahhrveqm1j9s1GuqaT7bKtdW2H60U7qrqPt0r2pfY//diTaTZk/+ OzV+2uEZGjP7Z32fkzD39HzzBUsXiSxuXfJtWebyeytDVp1e47J233rLDds2mWzestVk2/YdVjv373bd c3Zf2P4HB3MO/TzSfkz8+IqT1qfOnUk+++v8pIval45eSbz67/qcmza37t6pv6d8/8TDvMdiT/Y/y3wh - 8vLg6/y38u8ufGj6ZPr51dcF38N/Cvw69af1n+P//wANAA8013ReGAAAAAlwSFlzAAALEQAACxEBf2Rf - kQAAAV9JREFUWEftljtOA0EQRJ2QggRHICACYiIEEQkJCQfgAFyFa5ACCZcg5Q6IwPwCPtJST2pL0+M2 + 8vLg6/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OBs8S6jLNLSeILM4gckunE2W0ADn0HqC zOIWduTrdjYi9ouQM/yeKLO4gx+58cznsZtQcgOzP5lZXECL/Bkt/iyjOYZzeAqzkBsoN5NwDk9hFsP4 @@ -184,8 +184,8 @@ n19RsKnwXbF2SVbpqrI3FfqVJVW7ahhrveqm1j9s1GuqaT7bKtdW2H60U7qrqPt0r2pfY//diTaTZk/+ OzV+2uEZGjP7Z32fkzD39HzzBUsXiSxuXfJtWebyeytDVp1e47J233rLDds2mWzestVk2/YdVjv373bd c3Zf2P4HB3MO/TzSfkz8+IqT1qfOnUk+++v8pIval45eSbz67/qcmza37t6pv6d8/8TDvMdiT/Y/y3wh - 8vLg6/y38u8ufGj6ZPr51dcF38N/Cvw69af1n+P//wANAA8013ReGAAAAAlwSFlzAAALEQAACxEBf2Rf - kQAAAYpJREFUWEftlj1KxFAUhcdGFEQtxAW4Cl2CjVvQxtYVuAVbFQTBTm1nASK2gohoIbZWFlpoI2I8 + 8vLg6/y38u8ufGj6ZPr51dcF38N/Cvw69af1n+P//wANAA8013ReGAAAAAlwSFlzAAALDwAACw8BkvkD + pQAAAYpJREFUWEftlj1KxFAUhcdGFEQtxAW4Cl2CjVvQxtYVuAVbFQTBTm1nASK2gohoIbZWFlpoI2I8 X5Ind56XDIl5z8YDH7yc+5NDMoQZFEXxp7hmTlwzJ66ZE9dsYFKcC/QSgajR4826uGbNljgTJ+JYHIhr MU700MsMs+xgl3ePxgAs6Evs8u7RGOBQIB7vc0fCq2GXd4/GADNiXkwYry3MsoNdXn3sj3Ba7IgjsdsS Zphlh7e7xDUNcyI8xi5ilh3e7hLXNPwH8AJ8iPfqOCI8alZJAmyLZfFZXlXijEfNqvcAeyLUVjFqcQ7+ @@ -204,7 +204,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - 0.3.2 + 1.0.1 @@ -253,7 +253,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+ tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/ - 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEgAACxIB0t1+/AAADZdJREFUeF7lWwlQVFcW + 6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALEAAACxABrSO9dQAADZdJREFUeF7lWwlQVFcW /SDSbN30As2+qyMiSwOOisrWQBYzzoyKgIjlUhNNFA1uBImogGsSY4wajQaXCai4sK8KQjTGuKGjBomZ OEKjLEaJotHE5M59v7/Qn98q3QbSVZ6qU01f6t3HPf8t977/oADgpaZa48tEtcaXiRyDUCik+vTpw6Mo Si2lUqnxgAEDTFxdXVl0cXEx6devn8nAgQNpuru70+z4GT+xndFgLxlvbGSs4abtWQZHvrmqv3l3kcGM diff --git a/BandagedBD/Utilities.cs b/BandagedBD/Utilities.cs index d7ad22b..a2825b7 100644 --- a/BandagedBD/Utilities.cs +++ b/BandagedBD/Utilities.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; +using System.Net; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -155,4 +156,12 @@ namespace BandagedBD { return GetLatestVersion($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{version}"); } } + + public class TimedWebClient : WebClient { + protected override WebRequest GetWebRequest(Uri uri) { + WebRequest w = base.GetWebRequest(uri); + w.Timeout = 5 * 60 * 1000; + return w; + } + } }