private void Download() { ProgressScreen ps = new ProgressScreen($"Downloading {mod.identifier}"); NetAsyncModulesDownloader dl = new NetAsyncModulesDownloader(ps); ModuleInstaller inst = ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, ps); LaunchSubScreen( ps, () => { try { dl.DownloadModules(manager.Cache, new List <CkanModule> { mod }); if (!manager.Cache.IsMaybeCachedZip(mod)) { ps.RaiseError("Download failed, file is corrupted"); } } catch (Exception ex) { ps.RaiseError($"Download failed: {ex}"); } } ); // Don't let the installer re-use old screen references inst.User = null; }
private bool UpdateRegistry(ConsoleTheme theme, bool showNewModsPrompt = true) { ProgressScreen ps = new ProgressScreen("Updating Registry", "Checking for updates"); LaunchSubScreen(theme, ps, (ConsoleTheme th) => { HashSet <string> availBefore = new HashSet <string>( Array.ConvertAll <CkanModule, string>( registry.CompatibleModules( manager.CurrentInstance.VersionCriteria() ).ToArray(), (l => l.identifier) ) ); recent.Clear(); try { Repo.UpdateAllRepositories( RegistryManager.Instance(manager.CurrentInstance), manager.CurrentInstance, manager.Cache, ps ); } catch (ReinstallModuleKraken rmk) { ChangePlan reinstPlan = new ChangePlan(); foreach (CkanModule m in rmk.Modules) { reinstPlan.ToggleUpgrade(m); } LaunchSubScreen(theme, new InstallScreen(manager, reinstPlan, debug)); } catch (Exception ex) { // There can be errors while you re-install mods with changed metadata ps.RaiseError(ex.Message + ex.StackTrace); } // Update recent with mods that were updated in this pass foreach (CkanModule mod in registry.CompatibleModules( manager.CurrentInstance.VersionCriteria() )) { if (!availBefore.Contains(mod.identifier)) { recent.Add(mod.identifier); } } }); if (showNewModsPrompt && recent.Count > 0 && RaiseYesNoDialog(newModPrompt(recent.Count))) { searchBox.Clear(); moduleList.FilterString = searchBox.Value = "~n"; } RefreshList(theme); return(true); }