mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 20:07:21 +01:00
add try catch around each scan
This commit is contained in:
parent
ff2b679a8c
commit
7f97b20883
2 changed files with 22 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ public class FileDbManager
|
|||
return GetValidatedFileCache(matchingEntries.First());
|
||||
}
|
||||
|
||||
public FileCache? ValidateFileCache(FileCacheEntity fileCacheEntity)
|
||||
public FileCache? ValidateFileCacheEntity(FileCacheEntity fileCacheEntity)
|
||||
{
|
||||
return GetValidatedFileCache(fileCacheEntity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,11 +178,19 @@ public class PeriodicFileScanner : IDisposable
|
|||
{
|
||||
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
||||
{
|
||||
var file = _fileDbManager.ValidateFileCache(c);
|
||||
try
|
||||
{
|
||||
var file = _fileDbManager.ValidateFileCacheEntity(c);
|
||||
if (file != null)
|
||||
{
|
||||
scannedFiles[file.Filepath] = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed validating " + c.Filepath);
|
||||
Logger.Warn(ex.Message);
|
||||
}
|
||||
|
||||
Interlocked.Increment(ref currentFileProgress);
|
||||
})).ToArray();
|
||||
|
|
@ -202,9 +210,17 @@ public class PeriodicFileScanner : IDisposable
|
|||
foreach (var chunk in scannedFiles.Where(c => c.Value == false).Chunk(cpuCount))
|
||||
{
|
||||
Task[] tasks = chunk.Select(c => Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var entry = _fileDbManager.CreateFileEntry(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);
|
||||
})).ToArray();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue