From f57c75f4f93d3ba71419169403916522fcd9cc74 Mon Sep 17 00:00:00 2001 From: Daniel <790119+DanTheMan827@users.noreply.github.com> Date: Sun, 12 Apr 2020 19:34:52 -0500 Subject: [PATCH] #323 Don't reboot the system after installing each mod with "Download and Install" --- ModHub/Controls/ModHubTabControl.cs | 13 +++++++++++-- ModHub/ModHubForm.Designer.cs | 1 + ModHub/ModHubForm.cs | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ModHub/Controls/ModHubTabControl.cs b/ModHub/Controls/ModHubTabControl.cs index 724d32b9d..bf68e99d0 100644 --- a/ModHub/Controls/ModHubTabControl.cs +++ b/ModHub/Controls/ModHubTabControl.cs @@ -229,8 +229,10 @@ private IEnumerable GetItemDownloadTask(Repository.Repository.Item ite private void handleModDownload(bool install = false) { using (var tasker = new Tasks.Tasker(parentForm)) + using (var taskerForm = new TaskerForm()) { - tasker.AttachViews(new TaskerTaskbar(), new TaskerForm()); + + tasker.AttachViews(new TaskerTaskbar(), taskerForm); tasker.SetStatusImage(Resources.sign_cogs); tasker.SetTitle(Resources.Processing); @@ -246,8 +248,15 @@ private void handleModDownload(bool install = false) if (install && selectedMods.Count > 0) { + tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.MembootRecovery, forceRecoveryReload: false)); + tasker.AddTask(ShellTasks.ShellCommand("touch /user-recovery.flag")); + tasker.AddTask(ShellTasks.ShellCommand("touch /mod-recovery.flag")); tasker.AddTask(ShellTasks.MountBase); - tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.ProcessMods, selectedMods.ToArray())); + tasker.AddTask((Tasker innerTasker, object syncObject) => + { + tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.ProcessMods, selectedMods.ToArray())); + return Conclusion.Success; + }); } tasker.Start(); diff --git a/ModHub/ModHubForm.Designer.cs b/ModHub/ModHubForm.Designer.cs index ea649f37f..9d3ff3cfe 100644 --- a/ModHub/ModHubForm.Designer.cs +++ b/ModHub/ModHubForm.Designer.cs @@ -52,6 +52,7 @@ private void InitializeComponent() this.Name = "ModHubForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "ModHubForm"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ModHubForm_FormClosing); this.ResumeLayout(false); } diff --git a/ModHub/ModHubForm.cs b/ModHub/ModHubForm.cs index 72d76a59b..f96ac10f5 100644 --- a/ModHub/ModHubForm.cs +++ b/ModHub/ModHubForm.cs @@ -1,6 +1,7 @@ using com.clusterrr.hakchi_gui.Hmod.Controls; using com.clusterrr.hakchi_gui.ModHub.Controls; using com.clusterrr.hakchi_gui.Properties; +using com.clusterrr.hakchi_gui.Tasks; using System; using System.Collections.Generic; using System.Linq; @@ -83,5 +84,20 @@ public void LoadData(Repository.Repository repo) tabControl1.ResumeLayout(); } + + private void ModHubForm_FormClosing(object sender, FormClosingEventArgs e) + { + if (hakchi.Shell.IsOnline && hakchi.Shell.Execute("[ -e /mod-recovery.flag ]") == 0) + { + using (var tasker = new Tasker(this)) + { + tasker.AttachViews(new TaskerTaskbar(), new TaskerForm()); + tasker.SetStatusImage(Resources.sign_sync); + tasker.SetTitle(Resources.Rebooting); + tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.Memboot)); + tasker.Start(); + } + } + } } }