mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 19:47:21 +01:00
add ordering
This commit is contained in:
parent
8c8c3509d3
commit
6b5b45ff77
1 changed files with 2 additions and 2 deletions
|
|
@ -165,7 +165,7 @@ public class FileCleanupService : IHostedService
|
|||
DirectoryInfo dir = new(_cacheDir);
|
||||
var allFilesInDir = dir.GetFiles("*", SearchOption.AllDirectories);
|
||||
int filesToTake = 10000;
|
||||
var filesChunk = await dbContext.Files.Take(filesToTake).ToListAsync().ConfigureAwait(false);
|
||||
var filesChunk = await dbContext.Files.OrderBy(f => f.Hash).Take(filesToTake).ToListAsync().ConfigureAwait(false);
|
||||
int iterations = 1;
|
||||
var allFiles = new List<FileCache>();
|
||||
while (filesChunk.Any())
|
||||
|
|
@ -222,7 +222,7 @@ public class FileCleanupService : IHostedService
|
|||
}
|
||||
|
||||
allFiles.AddRange(filesChunk);
|
||||
filesChunk = await dbContext.Files.Skip(filesToTake * iterations).Take(filesToTake).ToListAsync(cancellationToken: ct).ConfigureAwait(false);
|
||||
filesChunk = await dbContext.Files.OrderBy(f => f.Hash).Skip(filesToTake * iterations).Take(filesToTake).ToListAsync(cancellationToken: ct).ConfigureAwait(false);
|
||||
iterations++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue