Added fail safes in compact of WOF incase
This commit is contained in:
@@ -138,7 +138,7 @@ public sealed class FileCompactor : IDisposable
|
|||||||
_compactionCts.Cancel();
|
_compactionCts.Cancel();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_compactionWorker.Wait(TimeSpan.FromSeconds(5)))
|
if (!_compactionWorker.Wait(TimeSpan.FromSeconds(5), _compactionCts.Token))
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Compaction worker did not shut down within timeout");
|
_logger.LogDebug("Compaction worker did not shut down within timeout");
|
||||||
}
|
}
|
||||||
@@ -463,10 +463,32 @@ public sealed class FileCompactor : IDisposable
|
|||||||
|
|
||||||
private static bool IsWOFCompactedFile(string filePath)
|
private static bool IsWOFCompactedFile(string filePath)
|
||||||
{
|
{
|
||||||
uint buf = 8;
|
try
|
||||||
_ = WofIsExternalFile(filePath, out int isExtFile, out uint _, out var info, ref buf);
|
{
|
||||||
if (isExtFile == 0) return false;
|
uint buf = (uint)Marshal.SizeOf<WOF_FILE_COMPRESSION_INFO_V1>();
|
||||||
return info.Algorithm == CompressionAlgorithm.XPRESS8K;
|
int result = WofIsExternalFile(filePath, out int isExternal, out uint _, out var info, ref buf);
|
||||||
|
|
||||||
|
if (result != 0 || isExternal == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return info.Algorithm == CompressionAlgorithm.XPRESS8K || info.Algorithm == CompressionAlgorithm.XPRESS4K
|
||||||
|
|| info.Algorithm == CompressionAlgorithm.XPRESS16K || info.Algorithm == CompressionAlgorithm.LZX;
|
||||||
|
}
|
||||||
|
catch (DllNotFoundException)
|
||||||
|
{
|
||||||
|
// WofUtil.dll not available
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (EntryPointNotFoundException)
|
||||||
|
{
|
||||||
|
// Running under Wine or non-NTFS systems
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Exception happened
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBtrfsCompressedFile(string path)
|
private bool IsBtrfsCompressedFile(string path)
|
||||||
|
|||||||
Reference in New Issue
Block a user