Skip to content

Commit

Permalink
Fixes 45
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Mar 9, 2020
1 parent 5929c4e commit 0e0f82d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 11 additions & 3 deletions SuperGrate/Classes/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public static async void CancelRemoteProfileDelete(string Host)
/// </summary>
/// <param name="Host">Host to get the architecture information from.</param>
/// <returns>CPU architecture.</returns>
public static Task<string> GetRemoteArch(string Host)
public static Task<OSArchitecture> GetRemoteArch(string Host)
{
Logger.Information("Reading OS Architecture...");
return Task.Run(() => {
Expand All @@ -492,7 +492,9 @@ public static Task<string> GetRemoteArch(string Host)
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject manObj in collection)
{
string arch = (string)manObj["OSArchitecture"];
string rawArch = (string)manObj["OSArchitecture"];
OSArchitecture arch = OSArchitecture.X86;
if (rawArch.Contains("64")) arch = OSArchitecture.X64;
Logger.Information("OS Architecture is: " + arch + ".");
return arch;
}
Expand All @@ -501,7 +503,7 @@ public static Task<string> GetRemoteArch(string Host)
{
Logger.Exception(e, "Failed to read the OS Architecture from host: " + Host + ".");
}
return null;
return OSArchitecture.Unknown;
});
}
/// <summary>
Expand All @@ -520,5 +522,11 @@ public static void MainMenuSetState(MainMenu Menu, bool Enabled, string[] Menus
mi.Enabled = Enabled;
}
}
public enum OSArchitecture
{
Unknown = 0,
X86 = 1,
X64 = 2
}
}
}
12 changes: 6 additions & 6 deletions SuperGrate/Classes/USMT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class USMT
private static bool Failed = false;
private static bool Running = false;
private static string CurrentTarget = "";
private static string DetectedArch = null;
private static Misc.OSArchitecture DetectedArch = Misc.OSArchitecture.Unknown;
private static string PayloadPathLocal
{
get {
Expand All @@ -32,11 +32,11 @@ private static string USMTPath
{
get
{
if(DetectedArch == "64-bit")
if(DetectedArch == Misc.OSArchitecture.X64)
{
return Config.Settings["USMTPathX64"];
}
if(DetectedArch == "32-bit")
if(DetectedArch == Misc.OSArchitecture.X64)
{
return Config.Settings["USMTPathX86"];
}
Expand All @@ -63,7 +63,7 @@ public static Task<bool> Do(USMTMode Mode, string[] IDs)
}
return Task.Run(async () => {
DetectedArch = await Misc.GetRemoteArch(CurrentTarget);
if (Canceled || DetectedArch == null) return false;
if (Canceled || DetectedArch == Misc.OSArchitecture.Unknown) return false;
Failed = !await CopyUSMT();
if (Canceled || Failed) return false;
Logger.UpdateProgress(0);
Expand Down Expand Up @@ -274,12 +274,12 @@ private static Task<bool> DownloadUSMTFromWeb()
Directory.CreateDirectory(USMTPath);
}
string dlPath = Path.Combine(USMTPath, "USMT.zip");
if (DetectedArch == "64-bit")
if (DetectedArch == Misc.OSArchitecture.X64)
{
success = await new Download("https://github.com/belowaverage-org/SuperGrate/raw/master/USMT/x64.zip", dlPath).Start();
if (!success) throw new Exception("Download failure.");
}
else if (DetectedArch == "32-bit")
else if (DetectedArch == Misc.OSArchitecture.X86)
{
success = await new Download("https://github.com/belowaverage-org/SuperGrate/raw/master/USMT/x86.zip", dlPath).Start();
if (!success) throw new Exception("Download failure.");
Expand Down

0 comments on commit 0e0f82d

Please sign in to comment.