Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show correct error messages after canceling (un)installations/upgrades #2602

Merged
merged 3 commits into from
Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 39 additions & 20 deletions GUI/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,43 @@ private void InstallMods(object sender, DoWorkEventArgs e) // this probably need
installCanceled = true;
};

bool resolvedAllProvidedMods = false;
// checks if all actions were successfull
bool resolvedAllProvidedMods = false;
// uninstall/installs/upgrades until every list is empty
// if the queue is NOT empty, resolvedAllProvidedMods is set to false until the action is done
while (!resolvedAllProvidedMods)
{
try
{
e.Result = new KeyValuePair<bool, ModChanges>(false, opts.Key);
if (!installCanceled && toUninstall.Count > 0)
if (toUninstall.Count > 0)
{
installer.UninstallList(toUninstall);
resolvedAllProvidedMods = false;
if (!installCanceled) {
installer.UninstallList(toUninstall);
resolvedAllProvidedMods = true;
HebaruSan marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (!installCanceled && toUpgrade.Count > 0)
if (toUpgrade.Count > 0)
{
installer.Upgrade(toUpgrade, downloader);
resolvedAllProvidedMods = false;
if (!installCanceled) {
installer.Upgrade(toUpgrade, downloader);
resolvedAllProvidedMods = true;
}
}
if (!installCanceled && toInstall.Count > 0)
if (toInstall.Count > 0)
{
installer.InstallList(toInstall, opts.Value, downloader);
resolvedAllProvidedMods = false;
if (!installCanceled) {
installer.InstallList(toInstall, opts.Value, downloader);
resolvedAllProvidedMods = true;
}
}
e.Result = new KeyValuePair<bool, ModChanges>(!installCanceled, opts.Key);
if (installCanceled)
{
return;
e.Result = new KeyValuePair<bool, ModChanges>(resolvedAllProvidedMods, opts.Key);
if (installCanceled) {
return;
}
resolvedAllProvidedMods = true;
}
catch (TooManyModsProvideKraken k)
{
Expand Down Expand Up @@ -327,7 +340,7 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)

tabController.SetTabLock(false);

if (result.Key)
if (result.Key && !installCanceled)
{
// Rebuilds the list of GUIMods
UpdateModsList(false, result.Value);
Expand All @@ -344,20 +357,26 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
AddStatusMessage("Success!");
HideWaitDialog(true);
tabController.HideTab("ChangesetTabPage");
// move to UpdateChangesDialog()?
ApplyToolButton.Enabled = false;
RetryCurrentActionButton.Visible = false;
UpdateChangesDialog(null, installWorker);
}
else
else if(installCanceled) {
// User cancelled the installation
// Rebuilds the list of GUIMods
UpdateModsList(false, result.Value);
UpdateChangesDialog(null, installWorker);
if (result.Key) {
FailWaitDialog("Cancellation to late, process complete!", "User canceled the process manually, but all mods already (un)installed/upgraded.", "Process complete!", result.Key);
} else {
FailWaitDialog("Process canceled by user!", "User canceled the process manually!", "(Un)Install/Upgrade canceled!", result.Key);
}
} else
{
// 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");
FailWaitDialog("Error during installation!", "An unknown error occurred, please try again!", "Installation failed!", result.Key);
UpdateChangesDialog(result.Value, installWorker);
RetryCurrentActionButton.Visible = true;
Util.Invoke(DialogProgressBar, () => DialogProgressBar.Style = ProgressBarStyle.Continuous);
Util.Invoke(DialogProgressBar, () => DialogProgressBar.Value = 0);
}

Util.Invoke(this, () => Enabled = true);
Expand Down
25 changes: 24 additions & 1 deletion GUI/MainWait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ public void HideWaitDialog(bool success)
});
}

/// <summary>
/// Stay on log page and reset StatusProgress
/// </summary>
/// <param name="statusMsg">Message for the lower status bar</param>
/// <param name="logMsg">Message to display on WaitDialog-Log (not the real log!)</param>
/// <param name="description">Message displayed above the DialogProgress bar</param>
public void FailWaitDialog(string statusMsg, string logMsg, string description, bool success)
{
Util.Invoke(statusStrip1, () => {
StatusProgress.Visible = false;
AddStatusMessage(statusMsg);
});
Util.Invoke(WaitTabPage, () => {
RecreateDialogs();
RetryCurrentActionButton.Visible = !success;
CancelCurrentActionButton.Enabled = false;
SetProgress(100);
});
tabController.HideTab("ChangesetTabPage");
AddLogMessage(logMsg);
SetDescription(description);
ApplyToolButton.Enabled = !success;
}

public void SetProgress(int progress)
{
if (progress < 0)
Expand Down Expand Up @@ -129,7 +153,6 @@ private void CancelCurrentActionButton_Click(object sender, EventArgs e)
{
CancelCurrentActionButton.Enabled = false;
});
HideWaitDialog(true);
}

}
Expand Down