Use Event->delete instead of our own delete code

This commit is contained in:
Isaac Connor 2015-12-21 12:31:48 -05:00
parent 2dfab0b408
commit 1039207f3a
1 changed files with 2 additions and 24 deletions

View File

@ -316,30 +316,8 @@ $dbh->ping();
{
if ( $delete_ok )
{
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId}\n" );
# Do it individually to avoid locking up the table for new events
my $sql = "delete from Events where Id = ?";
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
if ( ! $Config{ZM_OPT_FAST_DELETE} )
{
my $sql = "delete from Frames where EventId = ?";
my $sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
$sql = "delete from Stats where EventId = ?";
$sth = $dbh->prepare_cached( $sql )
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
$res = $sth->execute( $event->{Id} )
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
deleteEventFiles( $event->{Id}, $event->{MonitorId} );
}
my $Event = new ZoneMinder::Event( $$event{Id}, $event );
$event->delete();
}
else
{