feat: extract file listing

This commit is contained in:
Guillermo Marcel 2025-03-28 22:42:56 -03:00
parent 513a9d6d45
commit bd5044be42

View File

@ -19,7 +19,7 @@ public class AutoScanApp
private readonly IScheduler _scheduler;
private readonly IChainerListenerFactory _chainerListenerFactory;
public Func<AutoScanOptions, Task>? OnScanCompleted { get; set; }
public Func<Task>? OnScanCompleted { get; set; }
public AutoScanApp(IOptions<AutoScanOptions> options, ILogger<AutoScanApp> logger, IScheduler scheduler, IChainerListenerFactory chainerListenerFactory)
{
@ -72,7 +72,7 @@ public class AutoScanApp
.AddJob(downloaderJob)
.AddJob(scannerJob)
.AddJob(cleanJob)
.OnFinish(async () => await OnScanCompleted?.Invoke(_options))
.OnFinish(async () => await OnScanCompleted?.Invoke())
.Build();
_scheduler.ListenerManager.AddJobListener(chainer, GroupMatcher<JobKey>.GroupEquals(GROUP_NAME));
@ -89,6 +89,24 @@ public class AutoScanApp
var jobKey = new JobKey(JOBKEY_DOWNLOADER, "ScanGroup");
await _scheduler.TriggerJob(jobKey);
}
public string[] GetLastScanPictures()
{
if (_options.Scanner?.DetectionFolder is null)
return [];
return Directory.GetFiles(_options.Scanner.DetectionFolder , "*.jpg");
}
public string? GetVideoPath(string name)
{
var path = Path.Combine(_options.Scanner.DetectionFolder, name + ".avi");
if (!File.Exists(path))
{
_logger.LogWarning("File {Path} does not exist", path);
return null;
}
return path;
}
private string CronFromAt(string at)