From 5feb74c1c08594245e5a523339dc685d70c357c6 Mon Sep 17 00:00:00 2001 From: cake Date: Thu, 30 Oct 2025 03:46:55 +0100 Subject: [PATCH] Added another wine check in parralel with dalamud --- LightlessSync/FileCache/FileCompactor.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/LightlessSync/FileCache/FileCompactor.cs b/LightlessSync/FileCache/FileCompactor.cs index a8170f4..5f05549 100644 --- a/LightlessSync/FileCache/FileCompactor.cs +++ b/LightlessSync/FileCache/FileCompactor.cs @@ -364,7 +364,7 @@ public sealed class FileCompactor : IDisposable string realPath = path; bool isWine = _dalamudUtilService?.IsWine ?? false; - if (isWine) + if (isWine && IsProbablyWine()) { if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase)) { @@ -372,7 +372,6 @@ public sealed class FileCompactor : IDisposable } else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase)) { - // fallback for Wine's C:\ mapping realPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Personal), path.Substring(3).Replace('\\', '/') @@ -401,7 +400,6 @@ public sealed class FileCompactor : IDisposable return; } - // 4️⃣ Read process output var stdout = proc.StandardOutput.ReadToEnd(); var stderr = proc.StandardError.ReadToEnd(); proc.WaitForExit(); @@ -531,7 +529,7 @@ public sealed class FileCompactor : IDisposable bool isWine = _dalamudUtilService?.IsWine ?? false; string realPath = path; - if (isWine) + if (isWine && IsProbablyWine()) { if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase)) { @@ -539,10 +537,7 @@ public sealed class FileCompactor : IDisposable } else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase)) { - realPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.Personal), - path.Substring(3).Replace('\\', '/') - ).Replace('\\', '/'); + realPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), path.Substring(3).Replace('\\', '/')).Replace('\\', '/'); } _logger.LogTrace("Detected Wine environment. Converted path for filefrag: {realPath}", realPath); @@ -632,7 +627,7 @@ public sealed class FileCompactor : IDisposable try { string realPath = path; - if (_dalamudUtilService.IsWine) + if (_dalamudUtilService.IsWine && IsProbablyWine()) { realPath = ConvertWinePathToLinux(path); _logger.LogTrace("Detected Wine environment, remapped path: {realPath}", realPath); @@ -674,7 +669,7 @@ public sealed class FileCompactor : IDisposable } catch (Exception ex) { - _logger.LogWarning(ex, "Error running btrfs defragment for {file}", realPath); + _logger.LogWarning(ex, "Error running btrfs defragment for {file}", path); return false; } } @@ -758,4 +753,6 @@ public sealed class FileCompactor : IDisposable _logger.LogDebug("Queue has been cancelled by token"); } } + + private static bool IsProbablyWine() => Environment.GetEnvironmentVariable("WINELOADERNOEXEC") != null || Environment.GetEnvironmentVariable("WINEDLLPATH") != null || Directory.Exists("/proc/self") && File.Exists("/proc/mounts"); }