Compare commits

...

3 Commits

3 changed files with 34 additions and 8 deletions

View File

@ -79,6 +79,7 @@ public class AutoScanApp
await _scheduler.ScheduleJob(downloaderJob, trigger, cancellationToken);
await _scheduler.AddJob(scannerJob, false, true, cancellationToken);
await _scheduler.AddJob(cleanJob, false, true, cancellationToken);
_logger.LogDebug("Scheduled job successfully!");
}

View File

@ -48,6 +48,8 @@ public class DVRScanner : IDVRScanner
_logger.LogInformation("Dry run enabled, skipping execution...");
return;
}
CleanDetectionFiles();
_startedAt = DateTime.Now;
process.Start();
// process.PriorityClass = ProcessPriorityClass.High;
@ -66,7 +68,6 @@ public class DVRScanner : IDVRScanner
await UpdateProcessUntilExits(process, cancellationToken);
_logger.LogInformation("Videos scanned successfully!");
RemoveVideoFiles();
}
catch (Exception ex)
{
@ -87,16 +88,19 @@ public class DVRScanner : IDVRScanner
}
}
private void RemoveVideoFiles()
private void CleanDetectionFiles()
{
if (_options.Scanner?.DetectionFolder is null)
return;
if (_options.Scanner!.RunDry)
return;
//remove .avi files from the detection folder
if (_options.Scanner?.DetectionFolder is not null && !_options.Scanner.RunDry)
_logger.LogDebug("Removing .avi files from detection folder {DetectionFolder}", _options.Scanner.DetectionFolder);
foreach (var file in Directory.GetFiles(_options.Scanner!.DetectionFolder!, "*"))
{
_logger.LogDebug("Removing .avi files from detection folder {DetectionFolder}", _options.Scanner.DetectionFolder);
foreach (var file in Directory.GetFiles(_options.Scanner.DetectionFolder, "*.avi"))
{
File.Delete(file);
}
File.Delete(file);
}
}
}

View File

@ -34,11 +34,32 @@ public class CleanJob : IJob
private void CleanOriginalFiles()
{
if (_options.MediaFolder is not null)
return;
if (_options.RunDry)
return;
//remove .mp4 files from the media folder
_logger.LogDebug("Removing .mp4 files from media folder {MediaFolder}", _options.MediaFolder);
foreach (var file in Directory.GetFiles(_options.MediaFolder!, "*.mp4"))
{
File.Delete(file);
}
}
private void CleanDetectionFiles()
{
if (_options.Scanner?.DetectionFolder is not null)
return;
if (_options.Scanner!.RunDry)
return;
//remove .avi files from the detection folder
_logger.LogDebug("Removing .avi files from detection folder {DetectionFolder}", _options.Scanner.DetectionFolder);
foreach (var file in Directory.GetFiles(_options.Scanner!.DetectionFolder!, "*.avi"))
{
File.Delete(file);
}
}
}