Added another wine check in parralel with dalamud

This commit is contained in:
cake
2025-10-30 03:46:55 +01:00
parent c1770528f3
commit 5feb74c1c0

View File

@@ -364,7 +364,7 @@ public sealed class FileCompactor : IDisposable
string realPath = path; string realPath = path;
bool isWine = _dalamudUtilService?.IsWine ?? false; bool isWine = _dalamudUtilService?.IsWine ?? false;
if (isWine) if (isWine && IsProbablyWine())
{ {
if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase)) if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase))
{ {
@@ -372,7 +372,6 @@ public sealed class FileCompactor : IDisposable
} }
else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase)) else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase))
{ {
// fallback for Wine's C:\ mapping
realPath = Path.Combine( realPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Personal), Environment.GetFolderPath(Environment.SpecialFolder.Personal),
path.Substring(3).Replace('\\', '/') path.Substring(3).Replace('\\', '/')
@@ -401,7 +400,6 @@ public sealed class FileCompactor : IDisposable
return; return;
} }
// 4⃣ Read process output
var stdout = proc.StandardOutput.ReadToEnd(); var stdout = proc.StandardOutput.ReadToEnd();
var stderr = proc.StandardError.ReadToEnd(); var stderr = proc.StandardError.ReadToEnd();
proc.WaitForExit(); proc.WaitForExit();
@@ -531,7 +529,7 @@ public sealed class FileCompactor : IDisposable
bool isWine = _dalamudUtilService?.IsWine ?? false; bool isWine = _dalamudUtilService?.IsWine ?? false;
string realPath = path; string realPath = path;
if (isWine) if (isWine && IsProbablyWine())
{ {
if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase)) if (path.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase))
{ {
@@ -539,10 +537,7 @@ public sealed class FileCompactor : IDisposable
} }
else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase)) else if (path.StartsWith("C:\\", StringComparison.OrdinalIgnoreCase))
{ {
realPath = Path.Combine( realPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), path.Substring(3).Replace('\\', '/')).Replace('\\', '/');
Environment.GetFolderPath(Environment.SpecialFolder.Personal),
path.Substring(3).Replace('\\', '/')
).Replace('\\', '/');
} }
_logger.LogTrace("Detected Wine environment. Converted path for filefrag: {realPath}", realPath); _logger.LogTrace("Detected Wine environment. Converted path for filefrag: {realPath}", realPath);
@@ -632,7 +627,7 @@ public sealed class FileCompactor : IDisposable
try try
{ {
string realPath = path; string realPath = path;
if (_dalamudUtilService.IsWine) if (_dalamudUtilService.IsWine && IsProbablyWine())
{ {
realPath = ConvertWinePathToLinux(path); realPath = ConvertWinePathToLinux(path);
_logger.LogTrace("Detected Wine environment, remapped path: {realPath}", realPath); _logger.LogTrace("Detected Wine environment, remapped path: {realPath}", realPath);
@@ -674,7 +669,7 @@ public sealed class FileCompactor : IDisposable
} }
catch (Exception ex) 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; return false;
} }
} }
@@ -758,4 +753,6 @@ public sealed class FileCompactor : IDisposable
_logger.LogDebug("Queue has been cancelled by token"); _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");
} }