add try catch around each scan
This commit is contained in:
@@ -45,7 +45,7 @@ public class FileDbManager
|
|||||||
return GetValidatedFileCache(matchingEntries.First());
|
return GetValidatedFileCache(matchingEntries.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileCache? ValidateFileCache(FileCacheEntity fileCacheEntity)
|
public FileCache? ValidateFileCacheEntity(FileCacheEntity fileCacheEntity)
|
||||||
{
|
{
|
||||||
return GetValidatedFileCache(fileCacheEntity);
|
return GetValidatedFileCache(fileCacheEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,11 +178,19 @@ public class PeriodicFileScanner : IDisposable
|
|||||||
{
|
{
|
||||||
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
||||||
{
|
{
|
||||||
var file = _fileDbManager.ValidateFileCache(c);
|
try
|
||||||
|
{
|
||||||
|
var file = _fileDbManager.ValidateFileCacheEntity(c);
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
scannedFiles[file.Filepath] = true;
|
scannedFiles[file.Filepath] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Warn("Failed validating " + c.Filepath);
|
||||||
|
Logger.Warn(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
Interlocked.Increment(ref currentFileProgress);
|
Interlocked.Increment(ref currentFileProgress);
|
||||||
})).ToArray();
|
})).ToArray();
|
||||||
@@ -202,9 +210,17 @@ public class PeriodicFileScanner : IDisposable
|
|||||||
foreach (var chunk in scannedFiles.Where(c => c.Value == false).Chunk(cpuCount))
|
foreach (var chunk in scannedFiles.Where(c => c.Value == false).Chunk(cpuCount))
|
||||||
{
|
{
|
||||||
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var entry = _fileDbManager.CreateFileEntry(c.Key);
|
var entry = _fileDbManager.CreateFileEntry(c.Key);
|
||||||
if (entry == null) _ = _fileDbManager.CreateCacheEntry(c.Key);
|
if (entry == null) _ = _fileDbManager.CreateCacheEntry(c.Key);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Warn("Failed adding " + c.Key);
|
||||||
|
Logger.Warn(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
Interlocked.Increment(ref currentFileProgress);
|
Interlocked.Increment(ref currentFileProgress);
|
||||||
})).ToArray();
|
})).ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user