From 01a9cff6e195ce72d8f6cf02434c796e21e0cff4 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sat, 12 Nov 2022 10:43:39 +0000 Subject: [PATCH] Check if RFU is running before deleting/updating --- .../Helpers/Integrations/RbxFpsUnlocker.cs | 33 +++++++++++++++++-- Bloxstrap/Program.cs | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index ac2ded9..2139872 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -3,14 +3,13 @@ using System.IO; using System.IO.Compression; using System.Net.Http; -using Newtonsoft.Json.Linq; - using Bloxstrap.Models; namespace Bloxstrap.Helpers.Integrations { internal class RbxFpsUnlocker { + public const string ApplicationName = "rbxfpsunlocker"; public const string ProjectRepository = "axstin/rbxfpsunlocker"; // default settings but with QuickStart set to true and CheckForUpdates set to false @@ -25,6 +24,32 @@ namespace Bloxstrap.Helpers.Integrations "SilentErrors=false\n" + "QuickStart=true\n"; + public static void CheckIfRunning() + { + Process[] processes = Process.GetProcessesByName(ApplicationName); + + if (processes.Length == 0) + return; + + try + { + // try/catch just in case process was closed before prompt was answered + + foreach (Process process in processes) + { + if (process.MainModule is null || process.MainModule.FileName is null) + continue; + + if (!process.MainModule.FileName.Contains(Program.BaseDirectory)) + continue; + + process.Kill(); + process.Close(); + } + } + catch (Exception) { } + } + public static async Task CheckInstall() { if (Program.BaseDirectory is null) @@ -37,7 +62,10 @@ namespace Bloxstrap.Helpers.Integrations if (!Program.Settings.RFUEnabled) { if (Directory.Exists(folderLocation)) + { + CheckIfRunning(); Directory.Delete(folderLocation, true); + } return; } @@ -63,6 +91,7 @@ namespace Bloxstrap.Helpers.Integrations if (lastDownload > lastReleasePublish) return; + CheckIfRunning(); File.Delete(fileLocation); } diff --git a/Bloxstrap/Program.cs b/Bloxstrap/Program.cs index 79ed291..6e26b59 100644 --- a/Bloxstrap/Program.cs +++ b/Bloxstrap/Program.cs @@ -98,7 +98,7 @@ namespace Bloxstrap string commandLine = ""; -#if DEBUG +#if false //DEBUG new Preferences().ShowDialog(); #else if (args.Length > 0)