private void DownloadAllComponents() { if (!Directory.Exists(InstallerSettings.DownloadDirectory)) { Directory.CreateDirectory(InstallerSettings.DownloadDirectory); } Downloader = new ComponentDownloader(); Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged; List <InstallerComponent> components = InstallerComponents.Components; for (int i = 0; i < components.Count; i++) { InstallerComponent component = components[i]; // if it's disabled, // skip it if (!component.Enabled) { continue; } retry: ChangeProgressBarValue(0); Log($"Downloading {component.Name}..."); Downloader.DownloadComponent(ref component, InstallerSettings.DownloadDirectory); InstallerComponents.Components[i] = component; if (Downloader.Failed) { Log($"Downloading {component.Name} Failed"); // log Exception aswell, if it exists if (Downloader.Exception != null) { Log(Downloader.Exception.Message); Log(Downloader.Exception.StackTrace); } // ask the user if they want to retry DialogResult ret = MessageBox.Show("Download Failed, Try Again?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (ret == DialogResult.Yes) { // I know, I know, 'goto bad', but if you really hate this, // PR me a rework of this mess which doesn't use goto goto retry; } return; } } Log("Downloading completed"); LaunchInstallComponents(); }
private async Task DownloadAllComponents() { var downloader = new ComponentDownloader(); downloader.OnDownloadProgressChanged += OnDownloadProgressChanged; var components = InstallerSettings.InstallerComponents.Components; for (int i = 0; i < components.Count; i++) { InstallerComponent component = components[i]; // make sure component is enabled if (!component.Enabled) { continue; } bool useFallback = false; retry: try { ChangeProgressBarValue(0); Log($"Downloading {component.Name}..."); await downloader.DownloadComponent(i, InstallerSettings.DownloadDirectory, useFallback); } catch (Exception e) { Log($"Downloading {component.Name} Failed"); Log(e.Message); Log(e.StackTrace); if (component.FallbackUrls != null && !useFallback) { Log("Retrying With Fallback..."); useFallback = true; goto retry; } // ask the user if they want to retry DialogResult ret = MessageBox.Show("Download Failed, Try Again?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (ret == DialogResult.Yes) { useFallback = false; goto retry; } // early exit return; } } Log("Downloading completed"); LaunchInstallComponents(); }
private void DownloadAllComponents() { if (!Directory.Exists(InstallerSettings.DownloadDirectory)) { Directory.CreateDirectory(InstallerSettings.DownloadDirectory); } Downloader = new ComponentDownloader(); Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged; string project64FileName = Path.Combine(InstallerSettings.DownloadDirectory, "Project64.zip"); // we *sadly* need to do something special for Project64 Log("Downloading Project64..."); Downloader.Project64(project64FileName); if (Downloader.Failed) { Log("Downloading Project64 Failed"); Log(Downloader.Exception.Message); Log(Downloader.Exception.StackTrace); return; } foreach (InstallerComponent component in InstallerComponents.Components) { // if it's disabled, // skip it if (!component.Enabled) { continue; } ChangeProgressBarValue(0); Log($"Downloading {component.Name}..."); Downloader.DownloadComponent(component, InstallerSettings.DownloadDirectory); if (Downloader.Failed) { Log($"Downloading {component.Name} Failed"); // log Exception aswell, if it exists if (Downloader.Exception != null) { Log(Downloader.Exception.Message); Log(Downloader.Exception.StackTrace); } return; } } Log("Downloading completed"); LaunchInstallComponents(); }
private void DownloadAllComponents() { if (!Directory.Exists(InstallerSettings.DownloadDirectory)) { Directory.CreateDirectory(InstallerSettings.DownloadDirectory); } Downloader = new ComponentDownloader(); Downloader.OnDownloadProgressChanged += OnDownloadProgressChanged; List <InstallerComponent> components = InstallerComponents.Components; for (int i = 0; i < components.Count; i++) { InstallerComponent component = components[i]; // if it's disabled, // skip it if (!component.Enabled) { continue; } ChangeProgressBarValue(0); Log($"Downloading {component.Name}..."); Downloader.DownloadComponent(ref component, InstallerSettings.DownloadDirectory); InstallerComponents.Components[i] = component; if (Downloader.Failed) { Log($"Downloading {component.Name} Failed"); // log Exception aswell, if it exists if (Downloader.Exception != null) { Log(Downloader.Exception.Message); Log(Downloader.Exception.StackTrace); } return; } } Log("Downloading completed"); LaunchInstallComponents(); }