Fix warning

This commit is contained in:
2025-10-30 22:13:38 +01:00
parent d891dceb28
commit b4108c7803
40 changed files with 378 additions and 193 deletions

View File

@@ -1,4 +1,5 @@
using MareSynchronos.Interop.Ipc;
using System;
using MareSynchronos.Interop.Ipc;
using MareSynchronos.MareConfiguration;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
@@ -606,14 +607,35 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_scanCancellationTokenSource?.Cancel();
try
{
_scanCancellationTokenSource.Cancel();
}
catch (ObjectDisposedException)
{
}
_scanCancellationTokenSource.Dispose();
PenumbraWatcher?.Dispose();
MareWatcher?.Dispose();
SubstWatcher?.Dispose();
_penumbraFswCts?.CancelDispose();
_mareFswCts?.CancelDispose();
_substFswCts?.CancelDispose();
_periodicCalculationTokenSource?.CancelDispose();
TryCancelAndDispose(_penumbraFswCts);
TryCancelAndDispose(_mareFswCts);
TryCancelAndDispose(_substFswCts);
TryCancelAndDispose(_periodicCalculationTokenSource);
}
private static void TryCancelAndDispose(CancellationTokenSource? cts)
{
if (cts == null) return;
try
{
cts.Cancel();
}
catch (ObjectDisposedException)
{
}
cts.Dispose();
}
private void FullFileScan(CancellationToken ct)
@@ -856,4 +878,4 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
StartPenumbraWatcher(penumbraDir);
}
}
}
}

View File

@@ -12,7 +12,7 @@ public sealed class FileCompactor
private readonly Dictionary<string, int> _clusterSizes;
private readonly WOF_FILE_COMPRESSION_INFO_V1 _efInfo;
private readonly WofFileCompressionInfoV1 _efInfo;
private readonly ILogger<FileCompactor> _logger;
private readonly MareConfigService _mareConfigService;
@@ -24,7 +24,7 @@ public sealed class FileCompactor
_logger = logger;
_mareConfigService = mareConfigService;
_dalamudUtilService = dalamudUtilService;
_efInfo = new WOF_FILE_COMPRESSION_INFO_V1
_efInfo = new WofFileCompressionInfoV1
{
Algorithm = CompressionAlgorithm.XPRESS8K,
Flags = 0
@@ -123,7 +123,7 @@ public sealed class FileCompactor
out uint lpTotalNumberOfClusters);
[DllImport("WoFUtil.dll")]
private static extern int WofIsExternalFile([MarshalAs(UnmanagedType.LPWStr)] string Filepath, out int IsExternalFile, out uint Provider, out WOF_FILE_COMPRESSION_INFO_V1 Info, ref uint BufferLength);
private static extern int WofIsExternalFile([MarshalAs(UnmanagedType.LPWStr)] string Filepath, out int IsExternalFile, out uint Provider, out WofFileCompressionInfoV1 Info, ref uint BufferLength);
[DllImport("WofUtil.dll")]
private static extern int WofSetFileDataLocation(IntPtr FileHandle, ulong Provider, IntPtr ExternalFileInfo, ulong Length);
@@ -242,9 +242,9 @@ public sealed class FileCompactor
}
[StructLayout(LayoutKind.Sequential)]
private struct WOF_FILE_COMPRESSION_INFO_V1
private struct WofFileCompressionInfoV1
{
public CompressionAlgorithm Algorithm;
public ulong Flags;
}
}
}