Enables async parallel processing in media library scan job

This commit is contained in:
BinaryAlley committed 2025-03-01 19:15:43 +02:00
1 parent 46778b6408
commit 7b20a2fc52
3 files changed
+9 -9

No files matched your search

@@ -33,8 +33,8 @@ internal class FileHashService : IFileHashService
/// <param name="callback">Callback to invoke during processing of elements.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>A collection of files that changed since last library scan, along with their hashes.</returns>
public List<ChangedFileSystemFile> HashFiles(
List<FileInfo> files,
public async Task<List<ChangedFileSystemFile>> HashFilesAsync(
List<FileInfo> files,
Dictionary<string, LibraryScanResultEntity> previousScanResults,
Func<Task> callback,
CancellationToken cancellationToken)
@@ -49,7 +49,7 @@ internal class FileHashService : IFileHashService
CancellationToken = cancellationToken,
MaxDegreeOfParallelism = Environment.ProcessorCount
};
Parallel.ForEach(files, parallelOptions, async file =>
await Parallel.ForEachAsync(files, parallelOptions, async (file, cancellationToken) =>
{
cancellationToken.ThrowIfCancellationRequested();
try