From 74a2d35d3c20bf4d063a93df26e3f340d1c4ec25 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 6 Feb 2018 07:02:26 +0000 Subject: [PATCH] Make retry work if downloads fail --- GUI/Main.cs | 1 - GUI/MainChangeset.cs | 13 ++++++------- GUI/MainInstall.cs | 11 +++++++---- GUI/MainModList.cs | 10 +++++----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/GUI/Main.cs b/GUI/Main.cs index 1f00499a73..7b25644414 100644 --- a/GUI/Main.cs +++ b/GUI/Main.cs @@ -974,7 +974,6 @@ await mainModList.ComputeChangeSetFromModList( install_ops ) ); - UpdateChangesDialog(null, installWorker); ShowWaitDialog(); } } diff --git a/GUI/MainChangeset.cs b/GUI/MainChangeset.cs index 728ab9e535..72fcb1429b 100644 --- a/GUI/MainChangeset.cs +++ b/GUI/MainChangeset.cs @@ -32,7 +32,7 @@ public void UpdateChangesDialog(List changeset, BackgroundWorker inst IEnumerable leftOver = changeset.Where(change => change.ChangeType != GUIModChangeType.Remove && change.ChangeType != GUIModChangeType.Update); - + // Now make our list more human-friendly (dependencies for a mod are listed directly // after it.) CreateSortedModList(leftOver); @@ -74,7 +74,7 @@ public void UpdateChangesDialog(List changeset, BackgroundWorker inst /// It arranges the changeset in a human-friendly order /// The requested mod is listed first, it's dependencies right after it /// So we get for example "ModuleRCSFX" directly after "USI Exploration Pack" - /// + /// /// It is very likely that this is forward-compatible with new ChangeTypes's, /// like a a "reconfigure" changetype, but only the future will tell /// @@ -116,13 +116,12 @@ private void ConfirmChangesButton_Click(object sender, EventArgs e) //Using the changeset passed in can cause issues with versions. // An example is Mechjeb for FAR at 25/06/2015 with a 1.0.2 install. // TODO Work out why this is. - var user_change_set = mainModList.ComputeUserChangeSet().ToList(); installWorker.RunWorkerAsync( new KeyValuePair, RelationshipResolverOptions>( - user_change_set, install_ops)); - changeSet = null; - - UpdateChangesDialog(null, installWorker); + mainModList.ComputeUserChangeSet().ToList(), + install_ops + ) + ); ShowWaitDialog(); } diff --git a/GUI/MainInstall.cs b/GUI/MainInstall.cs index 99e9a6a194..1df7d80ee8 100644 --- a/GUI/MainInstall.cs +++ b/GUI/MainInstall.cs @@ -301,12 +301,13 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e) { KeyValuePair result = (KeyValuePair) e.Result; - UpdateModsList(false, result.Value); - tabController.SetTabLock(false); if (result.Key) { + // Rebuilds the list of GUIMods + UpdateModsList(false, result.Value); + if (modChangedCallback != null) { foreach (var mod in result.Value) @@ -320,13 +321,15 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e) HideWaitDialog(true); tabController.HideTab("ChangesetTabPage"); ApplyToolButton.Enabled = false; + UpdateChangesDialog(null, installWorker); } else { - // there was an error - // rollback user's choices but stay on the log dialog + // There was an error + // Stay on the log dialog and re-apply the user's change set to allow retry AddStatusMessage("Error!"); SetDescription("An error occurred, check the log for information"); + UpdateChangesDialog(result.Value, installWorker); Util.Invoke(DialogProgressBar, () => DialogProgressBar.Style = ProgressBarStyle.Continuous); Util.Invoke(DialogProgressBar, () => DialogProgressBar.Value = 0); } diff --git a/GUI/MainModList.cs b/GUI/MainModList.cs index 453e19f84f..5c80aad8f1 100644 --- a/GUI/MainModList.cs +++ b/GUI/MainModList.cs @@ -653,13 +653,13 @@ public static Dictionary ComputeConflictsFromModList(IRegistryQu public HashSet ComputeUserChangeSet() { - var changes = Modules.Where(mod => mod.IsInstallable()).Select(mod => mod.GetRequestedChange()); - var changeset = new HashSet( - changes.Where(change => change.HasValue). + return new HashSet(Modules. + Where(mod => mod.IsInstallable()). + Select(mod => mod.GetRequestedChange()). + Where(change => change.HasValue). Select(change => change.Value). Select(change => new ModChange(change.Key, change.Value, null)) - ); - return changeset; + ); } } }