Просмотр исходного кода

Fix updater breaking user execute permissions on Unix (#2055)

* Fix updater breaking user run permissions on *nix

The updater currently sets the permissions to user run only when the yes button is clicked, this changes it to run on Updater.cs after it's done updating as it should.

* Fix nits
pineappleEA 5 лет назад
Родитель
Сommit
1c49089ff0
2 измененных файлов с 15 добавлено и 7 удалено
  1. 1 7
      Ryujinx/Modules/Updater/UpdateDialog.cs
  2. 14 0
      Ryujinx/Modules/Updater/Updater.cs

+ 1 - 7
Ryujinx/Modules/Updater/UpdateDialog.cs

@@ -42,7 +42,7 @@ namespace Ryujinx.Modules
             YesButton.Clicked += YesButton_Clicked;
             YesButton.Clicked += YesButton_Clicked;
             NoButton.Clicked  += NoButton_Clicked;
             NoButton.Clicked  += NoButton_Clicked;
         }
         }
-        
+
         private void YesButton_Clicked(object sender, EventArgs args)
         private void YesButton_Clicked(object sender, EventArgs args)
         {
         {
             if (_restartQuery)
             if (_restartQuery)
@@ -51,12 +51,6 @@ namespace Ryujinx.Modules
                 string ryuExe  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
                 string ryuExe  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ryuName);
                 string ryuArg  = string.Join(" ", Environment.GetCommandLineArgs().AsEnumerable().Skip(1).ToArray());
                 string ryuArg  = string.Join(" ", Environment.GetCommandLineArgs().AsEnumerable().Skip(1).ToArray());
 
 
-                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
-                {
-                    UnixFileInfo unixFileInfo = new UnixFileInfo(ryuExe);
-                    unixFileInfo.FileAccessPermissions |= FileAccessPermissions.UserExecute;
-                }
-
                 Process.Start(ryuExe, ryuArg);
                 Process.Start(ryuExe, ryuArg);
 
 
                 Environment.Exit(0);
                 Environment.Exit(0);

+ 14 - 0
Ryujinx/Modules/Updater/Updater.cs

@@ -2,6 +2,7 @@ using Gtk;
 using ICSharpCode.SharpZipLib.GZip;
 using ICSharpCode.SharpZipLib.GZip;
 using ICSharpCode.SharpZipLib.Tar;
 using ICSharpCode.SharpZipLib.Tar;
 using ICSharpCode.SharpZipLib.Zip;
 using ICSharpCode.SharpZipLib.Zip;
+using Mono.Unix;
 using Newtonsoft.Json.Linq;
 using Newtonsoft.Json.Linq;
 using Ryujinx.Common.Logging;
 using Ryujinx.Common.Logging;
 using Ryujinx.Ui;
 using Ryujinx.Ui;
@@ -325,6 +326,17 @@ namespace Ryujinx.Modules
             }
             }
         }
         }
         
         
+        private static void SetUnixPermissions()
+        {
+            string ryuBin = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx");
+
+            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {
+                UnixFileInfo unixFileInfo = new UnixFileInfo(ryuBin);
+                unixFileInfo.FileAccessPermissions |= FileAccessPermissions.UserExecute;
+            }
+        }
+
         private static async void InstallUpdate(UpdateDialog updateDialog, string updateFile)
         private static async void InstallUpdate(UpdateDialog updateDialog, string updateFile)
         {
         {
             // Extract Update
             // Extract Update
@@ -444,6 +456,8 @@ namespace Ryujinx.Modules
 
 
             Directory.Delete(UpdateDir, true);
             Directory.Delete(UpdateDir, true);
 
 
+            SetUnixPermissions();
+
             updateDialog.MainText.Text      = "Update Complete!";
             updateDialog.MainText.Text      = "Update Complete!";
             updateDialog.SecondaryText.Text = "Do you want to restart Ryujinx now?";
             updateDialog.SecondaryText.Text = "Do you want to restart Ryujinx now?";
             updateDialog.Modal              = true;
             updateDialog.Modal              = true;