forked from amkovkov/GranuSightSoftware2
fix: ImagesStorageClear
This commit is contained in:
@@ -37,10 +37,12 @@ public partial class Program
|
||||
{
|
||||
_logger.LogInformation("Running images storage clear");
|
||||
|
||||
var unusedFiles = _imageStorageService.ListFiles()
|
||||
var recordsFiles = _context.ImageRecords.Select(r => r.ImagePath);
|
||||
var storedFiles = _imageStorageService.ListFiles()
|
||||
.Select(Path.GetFileName)
|
||||
.OfType<string>()
|
||||
.Where(f => !_context.ImageRecords.Any(r => r.ImagePath == f));
|
||||
.OfType<string>();
|
||||
|
||||
var unusedFiles = storedFiles.Except(recordsFiles);
|
||||
|
||||
if (unusedFiles is null || unusedFiles.Count() == 0)
|
||||
{
|
||||
@@ -51,7 +53,7 @@ public partial class Program
|
||||
|
||||
_logger.LogInformation("Found {} unused image(s):\n\t{}", unusedFiles.Count(), string.Join("\n\t", unusedFiles));
|
||||
|
||||
while (true)
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("Delete this files? (y/n) ");
|
||||
var input = Console.ReadLine()?.Trim();
|
||||
|
||||
Reference in New Issue
Block a user