updates to file scanner
This commit is contained in:
@@ -56,11 +56,14 @@ public class FileScannerService(MediaService mediaService, IConfiguration config
|
||||
try
|
||||
{
|
||||
var files = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
|
||||
var filesRelative = files.Select(f => Path.GetRelativePath(path, f)).ToArray();
|
||||
var existingFiles = await mediaService.GetExistingFilePathsAsync(cancellationToken);
|
||||
var upToDateFiles = existingFiles.Where(e => e.Value == MediaEntry.CUR_VERSION)
|
||||
.Select(e => e.Key)
|
||||
.ToFrozenSet();
|
||||
var filesToProcess = files.Where(f => !upToDateFiles.Contains(Path.GetRelativePath(path, f))).ToArray();
|
||||
var entriesToDelete = existingFiles.Keys.Except(filesRelative).ToArray();
|
||||
await mediaService.DeleteEntriesBulkAsync(files, cancellationToken);
|
||||
var filesToProcess = filesRelative.Where(f => !upToDateFiles.Contains(f)).ToArray();
|
||||
var total = 0;
|
||||
var prog = 0;
|
||||
foreach (var chunk in filesToProcess.Chunk(50))
|
||||
@@ -76,6 +79,7 @@ public class FileScannerService(MediaService mediaService, IConfiguration config
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task<int> ScanFileChunkAsync(string path, IEnumerable<string> files, FrozenDictionary<string, int> existingFiles, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var entries = new List<MediaEntry>();
|
||||
|
||||
Reference in New Issue
Block a user