add some locking around modifiedfiles

This commit is contained in:
Stanley Dimant
2022-09-03 17:57:09 +02:00
parent 8d6b7346ec
commit ce6764cbf8
2 changed files with 22 additions and 7 deletions

View File

@@ -123,9 +123,13 @@ namespace MareSynchronos.WebAPI
{
await using (var db = new FileCacheContext())
{
allFilesInDb = CurrentDownloads[currentDownloadId]
var fileCount = CurrentDownloads[currentDownloadId]
.Where(c => c.CanBeTransferred)
.All(h => db.FileCaches.Any(f => f.Hash == h.Hash));
.Count(h => db.FileCaches.Any(f => f.Hash == h.Hash));
var totalFiles = CurrentDownloads[currentDownloadId].Count(c => c.CanBeTransferred);
Logger.Debug("Waiting for files to be in the DB, added " + fileCount + " of " + totalFiles);
allFilesInDb = fileCount == totalFiles;
}
await Task.Delay(250, ct);