Skip to content

Commit

Permalink
Make retry work if downloads fail
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 6, 2018
1 parent bb02892 commit 74a2d35
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
1 change: 0 additions & 1 deletion GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ await mainModList.ComputeChangeSetFromModList(
install_ops
)
);
UpdateChangesDialog(null, installWorker);
ShowWaitDialog();
}
}
Expand Down
13 changes: 6 additions & 7 deletions GUI/MainChangeset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void UpdateChangesDialog(List<ModChange> changeset, BackgroundWorker inst

IEnumerable<ModChange> 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);
Expand Down Expand Up @@ -74,7 +74,7 @@ public void UpdateChangesDialog(List<ModChange> 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
/// </summary>
Expand Down Expand Up @@ -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<List<ModChange>, RelationshipResolverOptions>(
user_change_set, install_ops));
changeSet = null;

UpdateChangesDialog(null, installWorker);
mainModList.ComputeUserChangeSet().ToList(),
install_ops
)
);
ShowWaitDialog();
}

Expand Down
11 changes: 7 additions & 4 deletions GUI/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,13 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
{
KeyValuePair<bool, ModChanges> result = (KeyValuePair<bool, ModChanges>) 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)
Expand All @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions GUI/MainModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,13 @@ public static Dictionary<GUIMod, string> ComputeConflictsFromModList(IRegistryQu

public HashSet<ModChange> ComputeUserChangeSet()
{
var changes = Modules.Where(mod => mod.IsInstallable()).Select(mod => mod.GetRequestedChange());
var changeset = new HashSet<ModChange>(
changes.Where(change => change.HasValue).
return new HashSet<ModChange>(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;
);
}
}
}

0 comments on commit 74a2d35

Please sign in to comment.