diff --git a/src/CasaBot/AutoScan/Implementations/DVRScanner.cs b/src/CasaBot/AutoScan/Implementations/DVRScanner.cs index 444a777..8bdca5d 100644 --- a/src/CasaBot/AutoScan/Implementations/DVRScanner.cs +++ b/src/CasaBot/AutoScan/Implementations/DVRScanner.cs @@ -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); } + } } \ No newline at end of file