fix: clean detection folder before new scan
This commit is contained in:
parent
a0cc6ec55f
commit
513a9d6d45
@ -48,6 +48,8 @@ public class DVRScanner : IDVRScanner
|
|||||||
_logger.LogInformation("Dry run enabled, skipping execution...");
|
_logger.LogInformation("Dry run enabled, skipping execution...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CleanDetectionFiles();
|
||||||
_startedAt = DateTime.Now;
|
_startedAt = DateTime.Now;
|
||||||
process.Start();
|
process.Start();
|
||||||
// process.PriorityClass = ProcessPriorityClass.High;
|
// process.PriorityClass = ProcessPriorityClass.High;
|
||||||
@ -66,7 +68,6 @@ public class DVRScanner : IDVRScanner
|
|||||||
await UpdateProcessUntilExits(process, cancellationToken);
|
await UpdateProcessUntilExits(process, cancellationToken);
|
||||||
_logger.LogInformation("Videos scanned successfully!");
|
_logger.LogInformation("Videos scanned successfully!");
|
||||||
|
|
||||||
RemoveVideoFiles();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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
|
//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);
|
File.Delete(file);
|
||||||
foreach (var file in Directory.GetFiles(_options.Scanner.DetectionFolder, "*.avi"))
|
|
||||||
{
|
|
||||||
File.Delete(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user