mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 22:17:22 +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);
|
DirectoryInfo dir = new(_cacheDir);
|
||||||
var allFilesInDir = dir.GetFiles("*", SearchOption.AllDirectories);
|
var allFilesInDir = dir.GetFiles("*", SearchOption.AllDirectories);
|
||||||
int filesToTake = 10000;
|
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;
|
int iterations = 1;
|
||||||
var allFiles = new List<FileCache>();
|
var allFiles = new List<FileCache>();
|
||||||
while (filesChunk.Any())
|
while (filesChunk.Any())
|
||||||
|
|
@ -222,7 +222,7 @@ public class FileCleanupService : IHostedService
|
||||||
}
|
}
|
||||||
|
|
||||||
allFiles.AddRange(filesChunk);
|
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++;
|
iterations++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue