changed lightless references from you know what

This commit is contained in:
Zurazan
2025-08-24 15:06:46 +02:00
parent 33515a7481
commit d5b7bf42d1
129 changed files with 775 additions and 773 deletions

View File

@@ -1,5 +1,5 @@
using LightlessSync.Interop.Ipc;
using LightlessSync.MareConfiguration;
using LightlessSync.LightlessConfiguration;
using LightlessSync.Services;
using LightlessSync.Services.Mediator;
using LightlessSync.Utils;
@@ -11,7 +11,7 @@ namespace LightlessSync.FileCache;
public sealed class CacheMonitor : DisposableMediatorSubscriberBase
{
private readonly MareConfigService _configService;
private readonly LightlessConfigService _configService;
private readonly DalamudUtilService _dalamudUtil;
private readonly FileCompactor _fileCompactor;
private readonly FileCacheManager _fileDbManager;
@@ -22,8 +22,8 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
private readonly CancellationTokenSource _periodicCalculationTokenSource = new();
public static readonly IImmutableList<string> AllowedFileExtensions = [".mdl", ".tex", ".mtrl", ".tmb", ".pap", ".avfx", ".atex", ".sklb", ".eid", ".phyb", ".pbd", ".scd", ".skp", ".shpk"];
public CacheMonitor(ILogger<CacheMonitor> logger, IpcManager ipcManager, MareConfigService configService,
FileCacheManager fileDbManager, MareMediator mediator, PerformanceCollectorService performanceCollector, DalamudUtilService dalamudUtil,
public CacheMonitor(ILogger<CacheMonitor> logger, IpcManager ipcManager, LightlessConfigService configService,
FileCacheManager fileDbManager, LightlessMediator mediator, PerformanceCollectorService performanceCollector, DalamudUtilService dalamudUtil,
FileCompactor fileCompactor) : base(logger, mediator)
{
_ipcManager = ipcManager;
@@ -35,14 +35,14 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
Mediator.Subscribe<PenumbraInitializedMessage>(this, (_) =>
{
StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
StartMareWatcher(configService.Current.CacheFolder);
StartLightlessWatcher(configService.Current.CacheFolder);
InvokeScan();
});
Mediator.Subscribe<HaltScanMessage>(this, (msg) => HaltScan(msg.Source));
Mediator.Subscribe<ResumeScanMessage>(this, (msg) => ResumeScan(msg.Source));
Mediator.Subscribe<DalamudLoginMessage>(this, (_) =>
{
StartMareWatcher(configService.Current.CacheFolder);
StartLightlessWatcher(configService.Current.CacheFolder);
StartPenumbraWatcher(_ipcManager.Penumbra.ModDirectory);
InvokeScan();
});
@@ -57,7 +57,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
}
if (configService.Current.HasValidSetup())
{
StartMareWatcher(configService.Current.CacheFolder);
StartLightlessWatcher(configService.Current.CacheFolder);
InvokeScan();
}
@@ -102,37 +102,37 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
record WatcherChange(WatcherChangeTypes ChangeType, string? OldPath = null);
private readonly Dictionary<string, WatcherChange> _watcherChanges = new Dictionary<string, WatcherChange>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, WatcherChange> _mareChanges = new Dictionary<string, WatcherChange>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, WatcherChange> _lightlessChanges = new Dictionary<string, WatcherChange>(StringComparer.OrdinalIgnoreCase);
public void StopMonitoring()
{
Logger.LogInformation("Stopping monitoring of Penumbra and Mare storage folders");
MareWatcher?.Dispose();
Logger.LogInformation("Stopping monitoring of Penumbra and Lightless storage folders");
LightlessWatcher?.Dispose();
PenumbraWatcher?.Dispose();
MareWatcher = null;
LightlessWatcher = null;
PenumbraWatcher = null;
}
public bool StorageisNTFS { get; private set; } = false;
public void StartMareWatcher(string? marePath)
public void StartLightlessWatcher(string? lightlessPath)
{
MareWatcher?.Dispose();
if (string.IsNullOrEmpty(marePath) || !Directory.Exists(marePath))
LightlessWatcher?.Dispose();
if (string.IsNullOrEmpty(lightlessPath) || !Directory.Exists(lightlessPath))
{
MareWatcher = null;
Logger.LogWarning("Mare file path is not set, cannot start the FSW for Mare.");
LightlessWatcher = null;
Logger.LogWarning("Lightless file path is not set, cannot start the FSW for Lightless.");
return;
}
DriveInfo di = new(new DirectoryInfo(_configService.Current.CacheFolder).Root.FullName);
StorageisNTFS = string.Equals("NTFS", di.DriveFormat, StringComparison.OrdinalIgnoreCase);
Logger.LogInformation("Mare Storage is on NTFS drive: {isNtfs}", StorageisNTFS);
Logger.LogInformation("Lightless Storage is on NTFS drive: {isNtfs}", StorageisNTFS);
Logger.LogDebug("Initializing Mare FSW on {path}", marePath);
MareWatcher = new()
Logger.LogDebug("Initializing Lightless FSW on {path}", lightlessPath);
LightlessWatcher = new()
{
Path = marePath,
Path = lightlessPath,
InternalBufferSize = 8388608,
NotifyFilter = NotifyFilters.CreationTime
| NotifyFilters.LastWrite
@@ -143,23 +143,23 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
IncludeSubdirectories = false,
};
MareWatcher.Deleted += MareWatcher_FileChanged;
MareWatcher.Created += MareWatcher_FileChanged;
MareWatcher.EnableRaisingEvents = true;
LightlessWatcher.Deleted += LightlessWatcher_FileChanged;
LightlessWatcher.Created += LightlessWatcher_FileChanged;
LightlessWatcher.EnableRaisingEvents = true;
}
private void MareWatcher_FileChanged(object sender, FileSystemEventArgs e)
private void LightlessWatcher_FileChanged(object sender, FileSystemEventArgs e)
{
Logger.LogTrace("Mare FSW: FileChanged: {change} => {path}", e.ChangeType, e.FullPath);
Logger.LogTrace("Lightless FSW: FileChanged: {change} => {path}", e.ChangeType, e.FullPath);
if (!AllowedFileExtensions.Any(ext => e.FullPath.EndsWith(ext, StringComparison.OrdinalIgnoreCase))) return;
lock (_watcherChanges)
{
_mareChanges[e.FullPath] = new(e.ChangeType);
_lightlessChanges[e.FullPath] = new(e.ChangeType);
}
_ = MareWatcherExecution();
_ = LightlessWatcherExecution();
}
public void StartPenumbraWatcher(string? penumbraPath)
@@ -247,18 +247,18 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
}
private CancellationTokenSource _penumbraFswCts = new();
private CancellationTokenSource _mareFswCts = new();
private CancellationTokenSource _lightlessFswCts = new();
public FileSystemWatcher? PenumbraWatcher { get; private set; }
public FileSystemWatcher? MareWatcher { get; private set; }
public FileSystemWatcher? LightlessWatcher { get; private set; }
private async Task MareWatcherExecution()
private async Task LightlessWatcherExecution()
{
_mareFswCts = _mareFswCts.CancelRecreate();
var token = _mareFswCts.Token;
_lightlessFswCts = _lightlessFswCts.CancelRecreate();
var token = _lightlessFswCts.Token;
var delay = TimeSpan.FromSeconds(5);
Dictionary<string, WatcherChange> changes;
lock (_mareChanges)
changes = _mareChanges.ToDictionary(t => t.Key, t => t.Value, StringComparer.Ordinal);
lock (_lightlessChanges)
changes = _lightlessChanges.ToDictionary(t => t.Key, t => t.Value, StringComparer.Ordinal);
try
{
do
@@ -271,11 +271,11 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
return;
}
lock (_mareChanges)
lock (_lightlessChanges)
{
foreach (var key in changes.Keys)
{
_mareChanges.Remove(key);
_lightlessChanges.Remove(key);
}
}
@@ -458,9 +458,9 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
base.Dispose(disposing);
_scanCancellationTokenSource?.Cancel();
PenumbraWatcher?.Dispose();
MareWatcher?.Dispose();
LightlessWatcher?.Dispose();
_penumbraFswCts?.CancelDispose();
_mareFswCts?.CancelDispose();
_lightlessFswCts?.CancelDispose();
_periodicCalculationTokenSource?.CancelDispose();
}
@@ -478,7 +478,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
if (string.IsNullOrEmpty(_configService.Current.CacheFolder) || !Directory.Exists(_configService.Current.CacheFolder))
{
cacheDirExists = false;
Logger.LogWarning("Mare Cache directory is not set or does not exist.");
Logger.LogWarning("Lightless Cache directory is not set or does not exist.");
}
if (!penDirExists || !cacheDirExists)
{
@@ -681,7 +681,7 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
{
_configService.Current.InitialScanComplete = true;
_configService.Save();
StartMareWatcher(_configService.Current.CacheFolder);
StartLightlessWatcher(_configService.Current.CacheFolder);
StartPenumbraWatcher(penumbraDir);
}
}

View File

@@ -1,6 +1,6 @@
using K4os.Compression.LZ4.Legacy;
using LightlessSync.Interop.Ipc;
using LightlessSync.MareConfiguration;
using LightlessSync.LightlessConfiguration;
using LightlessSync.Services.Mediator;
using LightlessSync.Utils;
using Microsoft.Extensions.Hosting;
@@ -16,8 +16,8 @@ public sealed class FileCacheManager : IHostedService
public const string CachePrefix = "{cache}";
public const string CsvSplit = "|";
public const string PenumbraPrefix = "{penumbra}";
private readonly MareConfigService _configService;
private readonly MareMediator _mareMediator;
private readonly LightlessConfigService _configService;
private readonly LightlessMediator _lightlessMediator;
private readonly string _csvPath;
private readonly ConcurrentDictionary<string, List<FileCacheEntity>> _fileCaches = new(StringComparer.Ordinal);
private readonly SemaphoreSlim _getCachesByPathsSemaphore = new(1, 1);
@@ -26,12 +26,12 @@ public sealed class FileCacheManager : IHostedService
private readonly ILogger<FileCacheManager> _logger;
public string CacheFolder => _configService.Current.CacheFolder;
public FileCacheManager(ILogger<FileCacheManager> logger, IpcManager ipcManager, MareConfigService configService, MareMediator mareMediator)
public FileCacheManager(ILogger<FileCacheManager> logger, IpcManager ipcManager, LightlessConfigService configService, LightlessMediator lightlessMediator)
{
_logger = logger;
_ipcManager = ipcManager;
_configService = configService;
_mareMediator = mareMediator;
_lightlessMediator = lightlessMediator;
_csvPath = Path.Combine(configService.ConfigurationDirectory, "FileCache.csv");
}
@@ -82,7 +82,7 @@ public sealed class FileCacheManager : IHostedService
public Task<List<FileCacheEntity>> ValidateLocalIntegrity(IProgress<(int, int, FileCacheEntity)> progress, CancellationToken cancellationToken)
{
_mareMediator.Publish(new HaltScanMessage(nameof(ValidateLocalIntegrity)));
_lightlessMediator.Publish(new HaltScanMessage(nameof(ValidateLocalIntegrity)));
_logger.LogInformation("Validating local storage");
var cacheEntries = _fileCaches.SelectMany(v => v.Value).Where(v => v.IsCacheEntry).ToList();
List<FileCacheEntity> brokenEntities = [];
@@ -131,7 +131,7 @@ public sealed class FileCacheManager : IHostedService
}
}
_mareMediator.Publish(new ResumeScanMessage(nameof(ValidateLocalIntegrity)));
_lightlessMediator.Publish(new ResumeScanMessage(nameof(ValidateLocalIntegrity)));
return Task.FromResult(brokenEntities);
}
@@ -417,9 +417,9 @@ public sealed class FileCacheManager : IHostedService
{
if (!_ipcManager.Penumbra.APIAvailable || string.IsNullOrEmpty(_ipcManager.Penumbra.ModDirectory))
{
_mareMediator.Publish(new NotificationMessage("Penumbra not connected",
"Could not load local file cache data. Penumbra is not connected or not properly set up. Please enable and/or configure Penumbra properly to use Mare. After, reload Mare in the Plugin installer.",
MareConfiguration.Models.NotificationType.Error));
_lightlessMediator.Publish(new NotificationMessage("Penumbra not connected",
"Could not load local file cache data. Penumbra is not connected or not properly set up. Please enable and/or configure Penumbra properly to use Lightless. After, reload Lightless in the Plugin installer.",
LightlessConfiguration.Models.NotificationType.Error));
}
_logger.LogInformation("{csvPath} found, parsing", _csvPath);

View File

@@ -1,4 +1,4 @@
using LightlessSync.MareConfiguration;
using LightlessSync.LightlessConfiguration;
using LightlessSync.Services;
using Microsoft.Extensions.Logging;
using System.Runtime.InteropServices;
@@ -15,14 +15,14 @@ public sealed class FileCompactor
private readonly WOF_FILE_COMPRESSION_INFO_V1 _efInfo;
private readonly ILogger<FileCompactor> _logger;
private readonly MareConfigService _mareConfigService;
private readonly LightlessConfigService _lightlessConfigService;
private readonly DalamudUtilService _dalamudUtilService;
public FileCompactor(ILogger<FileCompactor> logger, MareConfigService mareConfigService, DalamudUtilService dalamudUtilService)
public FileCompactor(ILogger<FileCompactor> logger, LightlessConfigService lightlessConfigService, DalamudUtilService dalamudUtilService)
{
_clusterSizes = new(StringComparer.Ordinal);
_logger = logger;
_mareConfigService = mareConfigService;
_lightlessConfigService = lightlessConfigService;
_dalamudUtilService = dalamudUtilService;
_efInfo = new WOF_FILE_COMPRESSION_INFO_V1
{
@@ -50,7 +50,7 @@ public sealed class FileCompactor
MassCompactRunning = true;
int currentFile = 1;
var allFiles = Directory.EnumerateFiles(_mareConfigService.Current.CacheFolder).ToList();
var allFiles = Directory.EnumerateFiles(_lightlessConfigService.Current.CacheFolder).ToList();
int allFilesCount = allFiles.Count;
foreach (var file in allFiles)
{
@@ -82,7 +82,7 @@ public sealed class FileCompactor
{
await File.WriteAllBytesAsync(filePath, decompressedFile, token).ConfigureAwait(false);
if (_dalamudUtilService.IsWine || !_mareConfigService.Current.UseCompactor)
if (_dalamudUtilService.IsWine || !_lightlessConfigService.Current.UseCompactor)
{
return;
}

View File

@@ -1,6 +1,6 @@
using LightlessSync.API.Data.Enum;
using LightlessSync.MareConfiguration;
using LightlessSync.MareConfiguration.Configurations;
using LightlessSync.LightlessConfiguration;
using LightlessSync.LightlessConfiguration.Configurations;
using LightlessSync.PlayerData.Data;
using LightlessSync.PlayerData.Handlers;
using LightlessSync.Services;
@@ -26,7 +26,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
public bool IsTransientRecording { get; private set; } = false;
public TransientResourceManager(ILogger<TransientResourceManager> logger, TransientConfigService configurationService,
DalamudUtilService dalamudUtil, MareMediator mediator) : base(logger, mediator)
DalamudUtilService dalamudUtil, LightlessMediator mediator) : base(logger, mediator)
{
_configurationService = configurationService;
_dalamudUtil = dalamudUtil;