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");
|
_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)
|
.Select(Path.GetFileName)
|
||||||
.OfType<string>()
|
.OfType<string>();
|
||||||
.Where(f => !_context.ImageRecords.Any(r => r.ImagePath == f));
|
|
||||||
|
var unusedFiles = storedFiles.Except(recordsFiles);
|
||||||
|
|
||||||
if (unusedFiles is null || unusedFiles.Count() == 0)
|
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));
|
_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) ");
|
_logger.LogInformation("Delete this files? (y/n) ");
|
||||||
var input = Console.ReadLine()?.Trim();
|
var input = Console.ReadLine()?.Trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user