Implement a time function that gets unix_timestamp from StartTime, and implement check_for_files_in_filessytem
parent
fff54e4086
commit
1e52934dcf
|
@ -45,6 +45,7 @@ use parent qw(ZoneMinder::Object);
|
|||
use ZoneMinder::Config qw(:all);
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
use ZoneMinder::Database qw(:all);
|
||||
require Date::Parse;
|
||||
|
||||
use vars qw/ $table $primary_key /;
|
||||
$table = 'Events';
|
||||
|
@ -52,6 +53,17 @@ $primary_key = 'Id';
|
|||
|
||||
use POSIX;
|
||||
|
||||
sub Time {
|
||||
if ( @_ > 1 ) {
|
||||
$_[0]{Time} = $_[1];
|
||||
}
|
||||
if ( ! defined $_[0]{Time} ) {
|
||||
|
||||
$_[0]{Time} = Date::Parse::str2time( $_[0]{StartTime} );
|
||||
}
|
||||
return $_[0]{Time};
|
||||
}
|
||||
|
||||
sub Name {
|
||||
if ( @_ > 1 ) {
|
||||
$_[0]{Name} = $_[1];
|
||||
|
@ -96,9 +108,12 @@ sub find_one {
|
|||
}
|
||||
|
||||
sub getPath {
|
||||
return Path( @_ );
|
||||
}
|
||||
sub Path {
|
||||
my $event = shift;
|
||||
|
||||
my $Storage = $event->Storage();
|
||||
my $Storage = $event->Storage();
|
||||
|
||||
my $event_path = "";
|
||||
if ( $Config{ZM_USE_DEEP_STORAGE} ) {
|
||||
|
@ -106,7 +121,7 @@ sub getPath {
|
|||
$Storage->Path(),
|
||||
$event->{MonitorId},
|
||||
strftime( "%y/%m/%d/%H/%M/%S",
|
||||
localtime($event->{Time})
|
||||
localtime($event->Time())
|
||||
),
|
||||
);
|
||||
} else {
|
||||
|
@ -305,6 +320,11 @@ sub delete_files {
|
|||
sub Storage {
|
||||
return new ZoneMinder::Storage( $_[0]{StorageId} );
|
||||
}
|
||||
sub check_for_in_filesystem {
|
||||
my $path = $_[0]->Path();
|
||||
my @files = glob( $path . '/*' );
|
||||
return 1 if @files;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
|
|
@ -350,8 +350,12 @@ MAIN: while( $loop ) {
|
|||
while ( my ( $db_event, $age ) = each(%$db_events ) )
|
||||
{
|
||||
if ( !defined($fs_events->{$db_event}) ) {
|
||||
my $Event = new ZoneMinder::Event( $db_event );
|
||||
if ( $Event->check_for_in_filesystem() ) {
|
||||
Debug("Database events apparent exists at " . $Event->Path() );
|
||||
} else {
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
aud_print( "Database event '$db_monitor/$db_event' does not exist in filesystem" );
|
||||
aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path()." in filesystem" );
|
||||
if ( confirm() ) {
|
||||
my $res = $deleteEventSth->execute( $db_event )
|
||||
or Fatal( "Can't execute: ".$deleteEventSth->errstr() );
|
||||
|
@ -362,11 +366,11 @@ MAIN: while( $loop ) {
|
|||
$cleaned = 1;
|
||||
}
|
||||
} else {
|
||||
my $Event = new ZoneMinder::Event( $db_event );
|
||||
my $Storage = $Event->Storage();
|
||||
|
||||
aud_print( "Database event '".$Event->getPath()."/$db_monitor/$db_event' does not exist in filesystem but too young to delete.\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue