introduce files, has_capture_jpegs and has_analyse_jpegs functions to use in zmaudit. Improve delete debugging output

This commit is contained in:
Isaac Connor 2019-08-27 15:17:18 -04:00
parent b43093234f
commit 35d3a7d4fa
1 changed files with 28 additions and 1 deletions

View File

@ -370,7 +370,7 @@ sub delete {
if ( $$event{Id} ) {
# Need to have an event Id if we are to delete from the db.
Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}");
Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime} from ".$event->Path());
$ZoneMinder::Database::dbh->ping();
$ZoneMinder::Database::dbh->begin_work();
@ -800,6 +800,33 @@ sub recover_timestamps {
}
}
sub files {
my $self = shift;
if ( ! $$self{files} ) {
if ( ! opendir(DIR, $self->Path() ) ) {
Error("Can't open directory '$$self{Path}': $!");
return;
}
@{$$self{files}} = readdir(DIR);
Debug('Have ' . @{$$self{files}} . " files in $$self{Path}");
closedir(DIR);
}
return @{$$self{files}};
}
sub has_capture_jpegs {
@{$_[0]{capture_jpegs}} = grep(/^\d+\-capture\.jpg$/, $_[0]->files());
Debug("have " . @{$_[0]{capture_jpegs}} . " capture jpegs");
return @{$_[0]{capture_jpegs}} ? 1 : 0;
}
sub has_analyse_jpegs {
@{$_[0]{analyse_jpegs}} = grep(/^\d+\-analyse\.jpg$/, $_[0]->files());
Debug("have " . @{$_[0]{analyse_jpegs}} . " analyse jpegs");
return @{$_[0]{analyse_jpegs}} ? 1 : 0;
}
1;
__END__