fix minor FSW issues
This commit is contained in:
@@ -108,15 +108,18 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
|
|||||||
| NotifyFilters.DirectoryName
|
| NotifyFilters.DirectoryName
|
||||||
| NotifyFilters.Size,
|
| NotifyFilters.Size,
|
||||||
Filter = "*.*",
|
Filter = "*.*",
|
||||||
IncludeSubdirectories = false
|
IncludeSubdirectories = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
MareWatcher.Deleted += MareWatcher_FileChanged;
|
MareWatcher.Deleted += MareWatcher_FileChanged;
|
||||||
MareWatcher.Created += MareWatcher_FileChanged;
|
MareWatcher.Created += MareWatcher_FileChanged;
|
||||||
|
MareWatcher.EnableRaisingEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MareWatcher_FileChanged(object sender, FileSystemEventArgs e)
|
private void MareWatcher_FileChanged(object sender, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
|
Logger.LogTrace("Mare FSW: FileChanged: {change} => {path}", e.ChangeType, e.FullPath);
|
||||||
|
|
||||||
if (!_allowedExtensions.Any(ext => e.FullPath.EndsWith(ext, StringComparison.OrdinalIgnoreCase))) return;
|
if (!_allowedExtensions.Any(ext => e.FullPath.EndsWith(ext, StringComparison.OrdinalIgnoreCase))) return;
|
||||||
|
|
||||||
lock (_watcherChanges)
|
lock (_watcherChanges)
|
||||||
|
|||||||
@@ -83,18 +83,24 @@ public sealed class FileCacheManager : IHostedService
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var fileCache in cacheEntries)
|
foreach (var fileCache in cacheEntries)
|
||||||
{
|
{
|
||||||
|
if (cancellationToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
_logger.LogInformation("Validating {file}", fileCache.ResolvedFilepath);
|
_logger.LogInformation("Validating {file}", fileCache.ResolvedFilepath);
|
||||||
|
|
||||||
progress.Report((i, cacheEntries.Count, fileCache));
|
progress.Report((i, cacheEntries.Count, fileCache));
|
||||||
i++;
|
i++;
|
||||||
|
if (!File.Exists(fileCache.ResolvedFilepath))
|
||||||
|
{
|
||||||
|
brokenEntities.Add(fileCache);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var computedHash = Crypto.GetFileHash(fileCache.ResolvedFilepath);
|
var computedHash = Crypto.GetFileHash(fileCache.ResolvedFilepath);
|
||||||
if (!string.Equals(computedHash, fileCache.Hash, StringComparison.Ordinal))
|
if (!string.Equals(computedHash, fileCache.Hash, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Failed to validate {file}, got hash {hash}, expected hash {hash}", fileCache.ResolvedFilepath, computedHash, fileCache.Hash);
|
_logger.LogInformation("Failed to validate {file}, got hash {hash}, expected hash {hash}", fileCache.ResolvedFilepath, computedHash, fileCache.Hash);
|
||||||
brokenEntities.Add(fileCache);
|
brokenEntities.Add(fileCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cancellationToken.IsCancellationRequested) break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var brokenEntity in brokenEntities)
|
foreach (var brokenEntity in brokenEntities)
|
||||||
|
|||||||
Reference in New Issue
Block a user