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
This commit is contained in:
stan
2011-04-19 10:56:39 +00:00
parent bf101660b4
commit 27fedec37b

View File

@@ -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'] );
}
}
}
}