Implemented review from Thog!

This commit is contained in:
MelonSpeedruns 2020-02-07 16:01:46 -05:00
parent f7b6bfa87f
commit 0e929ac5e9
7 changed files with 76 additions and 69 deletions

View file

@ -1,8 +1,10 @@
using ICSharpCode.SharpZipLib.Tar;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Runtime.InteropServices;
namespace Ryujinx.Updater
{
@ -28,9 +30,11 @@ namespace Ryujinx.Updater
Directory.CreateDirectory(Path.Combine(dest, dirName));
}
}
catch
catch (Exception ex)
{
File.Create(Path.Combine(ryuDir, "UpdaterLog.txt")).Close();
File.WriteAllText(Path.Combine(ryuDir, "UpdaterLog.txt"), ex.Message);
Environment.Exit(0);
}
MoveAllFilesOver(directory, Path.Combine(dest, dirName));
@ -42,9 +46,11 @@ namespace Ryujinx.Updater
{
File.Move(file, Path.Combine(dest, Path.GetFileName(file)), true);
}
catch
catch (Exception ex)
{
File.Create(Path.Combine(ryuDir, "UpdaterLog.txt")).Close();
File.WriteAllText(Path.Combine(ryuDir, "UpdaterLog.txt"), ex.Message);
Environment.Exit(0);
}
}
}
@ -91,7 +97,19 @@ namespace Ryujinx.Updater
Console.WriteLine($"Extracting Ryujinx package...");
ZipFile.ExtractToDirectory(updateSaveLocation, localAppPath, true);
using (FileStream SourceStream = File.Open(updateSaveLocation, FileMode.Open))
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
TarArchive tarArchive = TarArchive.CreateInputTarArchive(SourceStream);
tarArchive.ExtractContents(localAppPath);
}
else
{
ZipArchive zipArchive = new ZipArchive(SourceStream);
zipArchive.ExtractToDirectory(localAppPath);
}
}
// Copy new files over to Ryujinx folder

View file

@ -19,5 +19,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.2.0" />
</ItemGroup>
</Project>

View file

@ -4,6 +4,7 @@ using Ryujinx.Configuration;
using Ryujinx.Debugger.Profiler;
using Ryujinx.Ui;
using System;
using System.Configuration;
using System.IO;
namespace Ryujinx
@ -55,17 +56,23 @@ namespace Ryujinx
}
MainWindow mainWindow = new MainWindow();
if (ConfigurationManager.AppSettings["Version"] != "__ver__")
{
mainWindow.Title = "Ryujinx " + ConfigurationManager.AppSettings["Version"];
}
mainWindow.Show();
if (args.Length > 1)
if (args.Length >= 1)
{
foreach (string arg in args)
if (args[0].ToUpper() == "/U")
{
switch (arg.Substring(0, 2).ToUpper())
{
case "/U": UpdateParser.BeginParse(); break;
default: mainWindow.LoadApplication(args[0]); break;
}
UpdateParser.BeginParse();
}
else
{
mainWindow.LoadApplication(args[0]);
}
}

View file

@ -77,6 +77,7 @@
<PackageReference Include="GtkSharp" Version="3.22.25.56" />
<PackageReference Include="GtkSharp.Dependencies" Version="1.1.0" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
</ItemGroup>
<ItemGroup>

View file

@ -1,6 +1,7 @@
using Gtk;
using Newtonsoft.Json.Linq;
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -44,21 +45,15 @@ namespace Ryujinx.Ui
Directory.CreateDirectory(localAppPath);
}
try
if (ConfigurationManager.AppSettings["Version"] != "__ver__")
{
string currentVersionJson;
string currentVersionBranch;
string currentVersionPr;
string currentVersion = ConfigurationManager.AppSettings["Version"];
string currentVersionBranch = ConfigurationManager.AppSettings["Branch"];
string currentVersionPr = ConfigurationManager.AppSettings["PrID"];
JObject VersionJSON = JObject.Parse(File.ReadAllText(System.IO.Path.Combine(Environment.CurrentDirectory, "Version.json")));
currentVersionJson = (string)VersionJSON["BuildVer"];
currentVersionPr = (string)VersionJSON["BuildPr"];
currentVersionBranch = (string)VersionJSON["BuildBranch"];
_versionText.Text = "Version - " + currentVersionJson + Environment.NewLine + "Branch - " + currentVersionBranch + Environment.NewLine + "PR ID - #" + currentVersionPr;
_versionText.Text = "Version - " + currentVersion + Environment.NewLine + "Branch - " + currentVersionBranch + Environment.NewLine + "PR ID - #" + currentVersionPr;
}
catch
else
{
_versionText.Text = "Unknown Version";
}

View file

@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq;
using Ryujinx.Common.Logging;
using Ryujinx.Ui;
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Net;
@ -46,6 +47,13 @@ namespace Ryujinx
_platformExt = "linux_x64.tar.gz";
}
}
else
{
Logger.PrintError(LogClass.Application, $"You are using an operating system architecture ({RuntimeInformation.ProcessArchitecture.ToString()}) not compatible with Ryujinx.");
GtkDialog.CreateErrorDialog($"You are using an operating system architecture ({RuntimeInformation.ProcessArchitecture.ToString()}) not compatible with Ryujinx.");
return;
}
// Begin the Appveyor parsing
@ -64,36 +72,16 @@ namespace Ryujinx
Directory.CreateDirectory(localAppPath);
}
// Get Version.json to compare versions
// Get Version from app.config to compare versions
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "Version.json")))
Version newVersion = Version.Parse(_buildVer);
Version currentVersion = Version.Parse(ConfigurationManager.AppSettings["Version"]);
if (newVersion < currentVersion)
{
try
{
string currentVersionJson;
string currentVersionBranch;
string currentVersionPr;
GtkDialog.CreateInfoDialog("Update", "Ryujinx - Updater", "You are already using the most updated version of Ryujinx!", "");
JObject VersionJSON = JObject.Parse(File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "Version.json")));
currentVersionJson = (string)VersionJSON["BuildVer"];
currentVersionPr = (string)VersionJSON["BuildPR"];
currentVersionBranch = (string)VersionJSON["BuildBranch"];
Version newVersion = Version.Parse(_buildVer);
Version currentVersion = Version.Parse(currentVersionJson);
if (newVersion < currentVersion)
{
GtkDialog.CreateInfoDialog("Update", "Ryujinx - Updater", "You are already using the most updated version of Ryujinx!", "");
return;
}
}
catch
{
}
return;
}
// Show a message asking the user if they want to update

View file

@ -12,35 +12,29 @@ environment:
config_name: '-profiled-'
build_script:
- ps: >-
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config).replace('__ver__', $env:APPVEYOR_BUILD_VERSION) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config).replace('__branch__', $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config).replace('__prid__', $env:APPVEYOR_PULL_REQUEST_NUMBER) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Ryujinx\App.config
dotnet --version
dotnet publish -c $env:config -r win-x64
dotnet publish -c $env:config -r linux-x64
dotnet publish -c $env:config -r osx-x64
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json).replace('_ver', $env:APPVEYOR_BUILD_VERSION) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json).replace('_pr', $env:APPVEYOR_PULL_REQUEST_NUMBER) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json
(Get-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json).replace('_branch', $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) | Set-Content -Path $env:APPVEYOR_BUILD_FOLDER\Version.json
Copy-Item $env:APPVEYOR_BUILD_FOLDER\Version.json -Destination $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\win-x64\publish\
dotnet publish -c $env:config -r linux-x64
dotnet publish -c $env:config -r osx-x64
7z a ryujinx$env:config_name$env:APPVEYOR_BUILD_VERSION-win_x64.zip $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\win-x64\publish\
Copy-Item $env:APPVEYOR_BUILD_FOLDER\Version.json -Destination $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\linux-x64\publish\
7z a ryujinx$env:config_name$env:APPVEYOR_BUILD_VERSION-linux_x64.tar $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\linux-x64\publish\
7z a ryujinx$env:config_name$env:APPVEYOR_BUILD_VERSION-linux_x64.tar.gz ryujinx$env:config_name$env:APPVEYOR_BUILD_VERSION-linux_x64.tar
Copy-Item $env:APPVEYOR_BUILD_FOLDER\Version.json -Destination $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\osx-x64\publish\
7z a ryujinx$env:config_name$env:APPVEYOR_BUILD_VERSION-osx_x64.zip $env:APPVEYOR_BUILD_FOLDER\Ryujinx\bin\$env:config\netcoreapp3.0\osx-x64\publish\
artifacts:
- path: ryujinx%config_name%%APPVEYOR_BUILD_VERSION%-win_x64.zip
- path: ryujinx%config_name%%APPVEYOR_BUILD_VERSION%-linux_x64.tar.gz
- path: ryujinx%config_name%%APPVEYOR_BUILD_VERSION%-osx_x64.zip
- path: ryujinx%config_name%%APPVEYOR_BUILD_VERSION%-osx_x64.zip