Random fixes

This commit is contained in:
Natsumi
2025-10-20 13:22:22 +11:00
parent b4cafe2f3d
commit 97ef396ec9
16 changed files with 79 additions and 22 deletions

View File

@@ -143,7 +143,7 @@ namespace VRCX
var output = new Dictionary<string, Dictionary<string, object>>();
using var regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\VRChat\VRChat");
if (regKey == null)
throw new Exception("Nothing to backup.");
throw new Exception("Failed to get VRC registry data");
var keys = regKey.GetValueNames();

View File

@@ -24,6 +24,26 @@ namespace VRCX
var fileName = Path.GetFileNameWithoutExtension(path);
if (!File.Exists(path) || !path.EndsWith(".png") || !fileName.StartsWith("VRChat_"))
return string.Empty;
// check if file is in use and we have permission to write
var success = false;
for (var i = 0; i < 10; i++)
{
try
{
using (File.Open(path, FileMode.Append, FileAccess.Write, FileShare.None))
{
success = true;
break;
}
}
catch (IOException)
{
Thread.Sleep(1000);
}
}
if (!success)
return string.Empty;
if (changeFilename)
{

View File

@@ -14,7 +14,6 @@ namespace VRCX
public partial class AppApi
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static readonly MD5 _hasher = MD5.Create();
public void Init()
{
@@ -30,7 +29,8 @@ namespace VRCX
public int GetColourFromUserID(string userId)
{
var hash = _hasher.ComputeHash(Encoding.UTF8.GetBytes(userId));
using var hasher = MD5.Create();
var hash = hasher.ComputeHash(Encoding.UTF8.GetBytes(userId));
return (hash[3] << 8) | hash[4];
}

View File

@@ -30,19 +30,24 @@ namespace VRCX
_steamPath = Path.Join(_homeDirectory, ".local/share/Steam");
var flatpakSteamPath = Path.Join(_homeDirectory, ".var/app/com.valvesoftware.Steam/.local/share/Steam");
if (!Directory.Exists(_steamPath) && Directory.Exists(flatpakSteamPath))
if (!IsValidSteamPath(_steamPath) && IsValidSteamPath(flatpakSteamPath))
{
logger.Info("Flatpak Steam detected.");
_steamPath = flatpakSteamPath;
}
var legacySteamPath = Path.Join(_homeDirectory, ".steam/steam");
if (!Directory.Exists(_steamPath) && Directory.Exists(legacySteamPath))
if (!IsValidSteamPath(_steamPath) && IsValidSteamPath(legacySteamPath))
{
logger.Info("Legacy Steam path detected.");
_steamPath = legacySteamPath;
}
if (!IsValidSteamPath(_steamPath))
{
logger.Error("No valid Steam library found.");
}
var libraryFoldersVdfPath = Path.Join(_steamPath, "config/libraryfolders.vdf");
var vrcLibraryPath = GetLibraryWithAppId(libraryFoldersVdfPath, vrchatAppid);
if (string.IsNullOrEmpty(vrcLibraryPath))
@@ -55,6 +60,11 @@ namespace VRCX
_vrcAppDataPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/LocalLow/VRChat/VRChat");
_vrcCrashesPath = Path.Join(_vrcPrefixPath, "drive_c/users/steamuser/AppData/Local/Temp/VRChat/VRChat/Crashes");
}
private static bool IsValidSteamPath(string path)
{
return File.Exists(Path.Join(path, "config/libraryfolders.vdf"));
}
private static string? GetLibraryWithAppId(string libraryFoldersVdfPath, string appId)
{

View File

@@ -611,10 +611,10 @@ namespace VRCX
public string GetVRChatRegistryJson()
{
var registry = new Dictionary<string, Dictionary<string, object>>();
string regCommand = "query \"HKEY_CURRENT_USER\\SOFTWARE\\VRChat\\VRChat\"";
const string regCommand = "query \"HKEY_CURRENT_USER\\SOFTWARE\\VRChat\\VRChat\"";
var queryResult = GetWineRegCommand(regCommand);
if (queryResult == null)
return null;
throw new Exception("Failed to get VRC registry data");
var lines = queryResult.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
.Where(line =>

View File

@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputPath>..\build\Cef\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<OutputType>WinExe</OutputType>
@@ -32,6 +31,7 @@
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<!-- Fix fail fast exception -->
<CETCompat>false</CETCompat>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>0</WarningLevel>
</PropertyGroup>