Updates now install properly

* Will need to continue testing and refining
This commit is contained in:
DrHacknik 2020-01-23 13:16:05 -05:00 committed by Ash
parent ce5f4b2a91
commit d469f294f0
4 changed files with 54 additions and 26 deletions

View file

@ -73,7 +73,11 @@ namespace Ryujinx
case "/U":
//Do that update stuffs
Updater.Update.PerformUpdate();
return;
break;
case "/C":
//Do that update stuffs
Updater.Update.Cleanup();
break;
default:
mainWindow.LoadApplication(args[0]);
break;

View file

@ -61,7 +61,7 @@ namespace Ryujinx.Ui
return messageDialog;
}
internal static async System.Threading.Tasks.Task<MessageDialog> CreateProgressDialogAsync(bool isInstall, string iconType, string titleMessage, string textMessage, string secText)
internal static MessageDialog CreateProgressDialog(string iconType, string titleMessage, string textMessage, string secText)
{
MessageDialog messageDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.None, null)
{
@ -71,16 +71,9 @@ namespace Ryujinx.Ui
SecondaryText = secText,
WindowPosition = WindowPosition.Center
};
Uri URL = new Uri(UpdateParser._BuildArt);
UpdateParser._Package.DownloadFileAsync(URL, Path.Combine(UpdateParser._RyuDir, "Data", "Update", "RyujinxPackage.zip"));
messageDialog.SetSizeRequest(100, 20);
if (isInstall == true)
{
await UpdateParser.ExtractPackageAsync();
}
else
{
Uri URL = new Uri(UpdateParser._BuildArt);
UpdateParser._Package.DownloadFileAsync(URL, Path.Combine(UpdateParser._RyuDir, "Data", "Update", "RyujinxPackage.zip"));
}
return messageDialog;
}
}

View file

@ -98,11 +98,10 @@ namespace Ryujinx.Updater.Parser
{
_Package.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
_Package.DownloadFileCompleted += new AsyncCompletedEventHandler(PackageDownloadedAsync);
using (MessageDialog dialog = await GtkDialog.CreateProgressDialogAsync(false, "Update", "Ryujinx - Update", "Downloading update " + _BuildVer, "Please wait while we download the latest package"))
using (MessageDialog dialog = GtkDialog.CreateProgressDialog("Update", "Ryujinx - Update", "Downloading update " + _BuildVer, "Please wait while we download the latest package and extract it."))
{
dialog.Run();
}
}
catch (Exception ex)
{
@ -121,11 +120,8 @@ namespace Ryujinx.Updater.Parser
else
{
Logger.PrintWarning(LogClass.Application, "Package is now installing");
using (MessageDialog dialog = await GtkDialog.CreateProgressDialogAsync(true, "Update", "Ryujinx - Update", "Installing update " + _BuildVer + "...", "Please wait while we install the latest package"))
{
dialog.Dispose();
dialog.Run();
}
await ExtractPackageAsync();
return;
}
}
@ -145,11 +141,12 @@ namespace Ryujinx.Updater.Parser
try
{
Process.Start(new ProcessStartInfo(Path.Combine(Environment.CurrentDirectory, "temp", "Ryujinx.exe"), "/U") { UseShellExecute = true });
Process.Start(new ProcessStartInfo(Path.Combine(Environment.CurrentDirectory, "temp", "publish", "Ryujinx.exe"), "/U") { UseShellExecute = true });
}
catch (System.ComponentModel.Win32Exception)
catch (Exception ex)
{
GtkDialog.CreateErrorDialog("Update canceled by user or the installation was not found");
GtkDialog.CreateErrorDialog("Package installation has failed\nCheck the log for more information.");
Logger.PrintError(LogClass.Application, "Package installation has failed\n" + ex.InnerException.ToString());
return;
}
Application.Quit();

View file

@ -1,5 +1,9 @@
using System;
using Gtk;
using Ryujinx.Common.Logging;
using Ryujinx.Ui;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
@ -7,15 +11,45 @@ namespace Ryujinx.Updater
{
public class Update
{
public static string _RyuDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx");
public static string RyuDir = Environment.CurrentDirectory;
private static string[] UpdateFiles = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory),"*", SearchOption.AllDirectories);
private static string ParentDir = Path.Combine(@"..\..");
public static void PerformUpdate()
{
return;
try
{
foreach (string _PathDir in Directory.GetDirectories(RyuDir, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(_PathDir.Replace(RyuDir, ParentDir));
foreach (string _PathNew in Directory.GetFiles(RyuDir, "*.*",
SearchOption.AllDirectories))
File.Copy(_PathNew, _PathNew.Replace(RyuDir, ParentDir), true);
Logger.PrintInfo(LogClass.Application, "Package installation was completed.\n");
GtkDialog.CreateInfoDialog("Update", "Ryujinx - Update", "Almost finished","The package was installed.\nPlease click ok, and the update will complete.");
try
{
Process.Start(new ProcessStartInfo(Path.Combine(ParentDir, "Ryujinx.exe"), "/C") { UseShellExecute = true });
}
catch (System.ComponentModel.Win32Exception)
{
GtkDialog.CreateErrorDialog("Update canceled by user or the installation was not found");
return;
}
Application.Quit();
return;
}
catch (System.ComponentModel.Win32Exception)
{
//Logger.PrintError(LogClass.Application, "Package installation has failed\n" + ex.InnerException.ToString());
GtkDialog.CreateErrorDialog("Package installation has failed\nCheck the log for more information.");
return;
}
}
private void Cleanup()
public static void Cleanup()
{
Directory.Delete(Path.Combine(RyuDir, "temp"), true);
return;
}
}