Skip to content

Commit

Permalink
Address "Access to the path is denied" error
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Sep 9, 2024
1 parent ff387cf commit 3f0ab22
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 24 deletions.
11 changes: 2 additions & 9 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,13 @@ public partial class App : Application

private static bool _showingExceptionDialog = false;

private static bool _terminating = false;

public static void Terminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS)
{
if (_terminating)
return;

int exitCodeNum = (int)exitCode;

Logger.WriteLine("App::Terminate", $"Terminating with exit code {exitCodeNum} ({exitCode})");

Current.Dispatcher.Invoke(() => Current.Shutdown(exitCodeNum));
// Environment.Exit(exitCodeNum);

_terminating = true;
Environment.Exit(exitCodeNum);
}

void GlobalExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs e)
Expand Down Expand Up @@ -109,6 +101,7 @@ public static void FinalizeExceptionHandling(Exception ex, bool log = true)
public static async Task<GithubRelease?> GetLatestRelease()
{
const string LOG_IDENT = "App::GetLatestRelease";

try
{
var releaseInfo = await Http.GetJson<GithubRelease>($"https://api.github.com/repos/{ProjectRepository}/releases/latest");
Expand Down
23 changes: 19 additions & 4 deletions Bloxstrap/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ public void DoInstall()
if (!IsImplicitInstall)
{
Filesystem.AssertReadOnly(Paths.Application);
File.Copy(Paths.Process, Paths.Application, true);

try
{
File.Copy(Paths.Process, Paths.Application, true);
}
catch (Exception ex)
{
App.Logger.WriteLine(LOG_IDENT, "Could not overwrite executable");
App.Logger.WriteException(LOG_IDENT, ex);

Frontend.ShowMessageBox(Strings.Installer_Install_CannotOverwrite, MessageBoxImage.Error);
App.Terminate(ErrorCode.ERROR_INSTALL_FAILURE);
}
}

// TODO: registry access checks, i'll need to look back on issues to see what the error looks like
Expand Down Expand Up @@ -259,8 +271,10 @@ public static void DoUninstall(bool keepData)

() => File.Delete(StartMenuShortcut),

() => Directory.Delete(Paths.Versions, true),
() => Directory.Delete(Paths.Downloads, true),
() => Directory.Delete(Paths.Roblox, true),

() => File.Delete(App.State.FileLocation)
};

if (!keepData)
Expand All @@ -270,8 +284,7 @@ public static void DoUninstall(bool keepData)
() => Directory.Delete(Paths.Modifications, true),
() => Directory.Delete(Paths.Logs, true),

() => File.Delete(App.Settings.FileLocation),
() => File.Delete(App.State.FileLocation), // TODO: maybe this should always be deleted? not sure yet
() => File.Delete(App.Settings.FileLocation)
});
}

Expand Down Expand Up @@ -525,6 +538,8 @@ public static void HandleUpgrade()
}

App.FastFlags.SetValue("FFlagFixGraphicsQuality", null);

Directory.Delete(Path.Combine(Paths.Base, "Versions"));
}

App.Settings.Save();
Expand Down
2 changes: 0 additions & 2 deletions Bloxstrap/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ static class Paths
public static string Downloads { get; private set; } = "";
public static string Logs { get; private set; } = "";
public static string Integrations { get; private set; } = "";
public static string Versions { get; private set; } = "";
public static string Modifications { get; private set; } = "";
public static string Roblox { get; private set; } = "";

Expand All @@ -36,7 +35,6 @@ public static void Initialize(string baseDirectory)
Downloads = Path.Combine(Base, "Downloads");
Logs = Path.Combine(Base, "Logs");
Integrations = Path.Combine(Base, "Integrations");
Versions = Path.Combine(Base, "Versions");
Modifications = Path.Combine(Base, "Modifications");
Roblox = Path.Combine(Base, "Roblox");

Expand Down
11 changes: 11 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1177,4 +1177,9 @@ Are you sure you want to continue?</value>
<data name="Dialog.Connectivity.RobloxUpgradeNeeded" xml:space="preserve">
<value>Because Roblox needs to be installed or upgraded, Bloxstrap cannot continue.</value>
</data>
<data name="Installer.Install.CannotOverwrite" xml:space="preserve">
<value>Bloxstrap has been installed to this location before and is still present, however the installer cannot overwrite the old executable.

Please manually delete Bloxstrap.exe from the install location or try restarting your system, and then retry installation afterwards.</value>
</data>
</root>
6 changes: 0 additions & 6 deletions Bloxstrap/UI/ViewModels/Installer/InstallViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;

using Bloxstrap.Resources;

using Microsoft.Win32;
using Wpf.Ui.Mvvm.Interfaces;
using System.ComponentModel;

namespace Bloxstrap.UI.ViewModels.Installer
{
public class InstallViewModel : NotifyPropertyChangedViewModel
Expand Down
5 changes: 2 additions & 3 deletions Bloxstrap/Utilities.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel;
using System.Security.Principal;

namespace Bloxstrap
{
Expand Down Expand Up @@ -52,9 +51,9 @@ public static VersionComparison CompareVersions(string versionStr1, string versi
public static string GetRobloxVersion(bool studio)
{
string versionGuid = studio ? App.State.Prop.Studio.VersionGuid : App.State.Prop.Player.VersionGuid;
string fileName = studio ? "RobloxStudioBeta.exe" : "RobloxPlayerBeta.exe";
string fileName = studio ? "Studio/RobloxStudioBeta.exe" : "Player/RobloxPlayerBeta.exe";

string playerLocation = Path.Combine(Paths.Versions, versionGuid, fileName);
string playerLocation = Path.Combine(Paths.Roblox, fileName);

if (!File.Exists(playerLocation))
return "";
Expand Down

0 comments on commit 3f0ab22

Please sign in to comment.