From 27fedec37b84ae8272ea46af90fb37e4e6e5d66c Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 19 Apr 2011 10:56:39 +0000 Subject: [PATCH] Reordered monitor deletion to do primary activities first in case of deletions timing out git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3324 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/includes/actions.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index c78717511..f67dc622a 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -550,20 +550,27 @@ if ( !empty($action) ) zmcControl( $monitor, "stop" ); } - $sql = "select Id from Events where MonitorId = '".dbEscape($markMid)."'"; - $markEids = dbFetchAll( $sql, 'Id' ); - foreach( $markEids as $markEid ) - deleteEvent( $markEid ); - - @unlink( ZM_DIR_EVENTS."/".$monitor['Name'] ); - system( "rm -rf ".ZM_DIR_EVENTS."/".$monitor['Id'] ); - + // This is the important stuff + dbQuery( "delete from Monitors where Id = '".dbEscape($markMid)."'" ); dbQuery( "delete from Zones where MonitorId = '".dbEscape($markMid)."'" ); if ( ZM_OPT_X10 ) dbQuery( "delete from TriggersX10 where MonitorId = '".dbEscape($markMid)."'" ); - dbQuery( "delete from Monitors where Id = '".dbEscape($markMid)."'" ); fixSequences(); + + // If fast deletes are on, then zmaudit will clean everything else up later + // If fast deletes are off and there are lots of events then this step may + // well time out before completing, in which case zmaudit will still tidy up + if ( !ZM_OPT_FAST_DELETE ) + { + $sql = "select Id from Events where MonitorId = '".dbEscape($markMid)."'"; + $markEids = dbFetchAll( $sql, 'Id' ); + foreach( $markEids as $markEid ) + deleteEvent( $markEid ); + + deletePath( ZM_DIR_EVENTS."/".$monitor['Name'] ); + deletePath( ZM_DIR_EVENTS."/".$monitor['Id'] ); + } } } }