Warning cleansing process
This commit is contained in:
@@ -85,7 +85,7 @@ public sealed partial class FileCompactor : IDisposable
|
||||
int workerId = i;
|
||||
|
||||
_workers.Add(Task.Factory.StartNew(
|
||||
() => ProcessQueueWorkerAsync(_compactionCts.Token, workerId),
|
||||
() => ProcessQueueWorkerAsync(workerId, _compactionCts.Token),
|
||||
_compactionCts.Token,
|
||||
TaskCreationOptions.LongRunning,
|
||||
TaskScheduler.Default).Unwrap());
|
||||
@@ -120,7 +120,8 @@ public sealed partial class FileCompactor : IDisposable
|
||||
var folder = _lightlessConfigService.Current.CacheFolder;
|
||||
if (string.IsNullOrWhiteSpace(folder) || !Directory.Exists(folder))
|
||||
{
|
||||
_logger.LogWarning("Filecompacator couldnt find your Cache folder: {folder}", folder);
|
||||
if (_logger.IsEnabled(LogLevel.Warning))
|
||||
_logger.LogWarning("Filecompacator couldnt find your Cache folder: {folder}", folder);
|
||||
Progress = "0/0";
|
||||
return;
|
||||
}
|
||||
@@ -281,12 +282,15 @@ public sealed partial class FileCompactor : IDisposable
|
||||
return (flowControl: false, value: blocks * 512L);
|
||||
}
|
||||
|
||||
_logger.LogDebug("Btrfs size probe failed for {linux} (exit {code}). stdout='{so}' stderr='{se}'. Falling back to Length.", linuxPath, res.code, outTrim, (res.se ?? "").Trim());
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
_logger.LogDebug("Btrfs size probe failed for {linux} (exit {code}). stdout='{so}' stderr='{se}'. Falling back to Length.", linuxPath, res.code, outTrim, (res.se ?? "").Trim());
|
||||
|
||||
return (flowControl: false, value: fileInfo.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed Btrfs size probe for {file}, using Length", fileInfo.FullName);
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
_logger.LogDebug(ex, "Failed Btrfs size probe for {file}, using Length", fileInfo.FullName);
|
||||
return (flowControl: true, value: fileInfo.Length);
|
||||
}
|
||||
}
|
||||
@@ -307,7 +311,8 @@ public sealed partial class FileCompactor : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed stat size for {file}, fallback to Length", fileInfo.FullName);
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
_logger.LogDebug(ex, "Failed stat size for {file}, fallback to Length", fileInfo.FullName);
|
||||
}
|
||||
|
||||
return (flowControl: true, value: default);
|
||||
@@ -323,7 +328,8 @@ public sealed partial class FileCompactor : IDisposable
|
||||
var fi = new FileInfo(filePath);
|
||||
if (!fi.Exists)
|
||||
{
|
||||
_logger.LogTrace("[W{worker}] Skip compaction: missing {file}", workerId, filePath);
|
||||
if (_logger.IsEnabled(LogLevel.Trace))
|
||||
_logger.LogTrace("[W{worker}] Skip compaction: missing {file}", workerId, filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,7 +344,8 @@ public sealed partial class FileCompactor : IDisposable
|
||||
|
||||
if (oldSize < minSizeBytes)
|
||||
{
|
||||
_logger.LogTrace("[W{worker}] Skip compaction: {file} ({size} B) < threshold ({th} B)", workerId, filePath, oldSize, minSizeBytes);
|
||||
if (_logger.IsEnabled(LogLevel.Trace))
|
||||
_logger.LogTrace("[W{worker}] Skip compaction: {file} ({size} B) < threshold ({th} B)", workerId, filePath, oldSize, minSizeBytes);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -358,7 +365,8 @@ public sealed partial class FileCompactor : IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogTrace("[W{worker}] Already NTFS-compressed with XPRESS8K: {file}", workerId, filePath);
|
||||
if (_logger.IsEnabled(LogLevel.Trace))
|
||||
_logger.LogTrace("[W{worker}] Already NTFS-compressed with XPRESS8K: {file}", workerId, filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -379,12 +387,14 @@ public sealed partial class FileCompactor : IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogTrace("[W{worker}] Already Btrfs-compressed with clzo: {file}", workerId, filePath);
|
||||
if (_logger.IsEnabled(LogLevel.Trace))
|
||||
_logger.LogTrace("[W{worker}] Already Btrfs-compressed with clzo: {file}", workerId, filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogTrace("[W{worker}] Skip compact: unsupported FS for {file}", workerId, filePath);
|
||||
if (_logger.IsEnabled(LogLevel.Trace))
|
||||
_logger.LogTrace("[W{worker}] Skip compact: unsupported FS for {file}", workerId, filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1045,10 +1055,10 @@ public sealed partial class FileCompactor : IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the queue with, meant for a worker/thread
|
||||
/// Process the queue, meant for a worker/thread
|
||||
/// </summary>
|
||||
/// <param name="token">Cancellation token for the worker whenever it needs to be stopped</param>
|
||||
private async Task ProcessQueueWorkerAsync(CancellationToken token, int workerId)
|
||||
private async Task ProcessQueueWorkerAsync(int workerId, CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1139,17 +1149,18 @@ public sealed partial class FileCompactor : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_isWindows)
|
||||
{
|
||||
using var _ = new FileStream(winePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
}
|
||||
else
|
||||
{
|
||||
using var _ = new FileStream(linuxPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
}
|
||||
var pathToOpen = _isWindows ? winePath : linuxPath;
|
||||
|
||||
if (string.IsNullOrEmpty(pathToOpen) || !File.Exists(pathToOpen))
|
||||
return false;
|
||||
|
||||
using var _ = new FileStream(pathToOpen, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
return true;
|
||||
}
|
||||
catch { return false; }
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user