Check and Fix Scheme and StorageArea
This commit is contained in:
parent
82abd04f36
commit
4ddd328c61
|
@ -508,13 +508,18 @@ MAIN: while( $loop ) {
|
|||
|
||||
# Foreach database monitor and it's list of events.
|
||||
while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) {
|
||||
Debug("Checking db events for monitor $db_monitor");
|
||||
if ( ! $db_events ) {
|
||||
Debug("Skipping db events for $db_monitor because there are none");
|
||||
next;
|
||||
}
|
||||
|
||||
# If we found the monitor in the file system
|
||||
if ( my $fs_events = $fs_monitors->{$db_monitor} ) {
|
||||
next if ! $db_events;
|
||||
my $fs_events = $fs_monitors->{$db_monitor};
|
||||
|
||||
while ( my ( $db_event, $age ) = each( %$db_events ) ) {
|
||||
if ( ! defined( $fs_events->{$db_event} ) ) {
|
||||
if ( ! ($fs_events and defined( $fs_events->{$db_event} ) ) ) {
|
||||
Debug("Don't have an fs event for $db_event");
|
||||
my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
|
||||
if ( ! $Event ) {
|
||||
Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing.");
|
||||
|
@ -556,20 +561,23 @@ MAIN: while( $loop ) {
|
|||
aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" );
|
||||
}
|
||||
} # end if exists in filesystem
|
||||
} else {
|
||||
Debug("Found fs event for $db_event, $age at " . $$fs_events{$db_event}->Path());
|
||||
my $Event = new ZoneMinder::Event( $db_event );
|
||||
if ( ! $Event->check_for_in_filesystem() ) {
|
||||
Warning("Not found at " . $Event->Path() );
|
||||
if ( $$fs_events{$db_event}->Scheme() ne $Event->Scheme() ) {
|
||||
Info("Updating scheme on event $$Event{Id} from $$Event{Scheme} to $$fs_events{$db_event}{Scheme}");
|
||||
$Event->Scheme($$fs_events{$db_event}->Scheme());
|
||||
}
|
||||
if ( $$fs_events{$db_event}->StorageId() != $Event->StorageId() ) {
|
||||
Info("Updating storage area on event $$Event{Id} from $$Event{StorageId} to $$fs_events{$db_event}{StorageId}");
|
||||
$Event->StorageId($$fs_events{$db_event}->StorageId());
|
||||
}
|
||||
$Event->save();
|
||||
}
|
||||
} # end if ! in fs_events
|
||||
} # foreach db_event
|
||||
#} else {
|
||||
#my $Monitor = new ZoneMinder::Monitor( $db_monitor );
|
||||
#my $Storage = $Monitor->Storage();
|
||||
#aud_print( "Database monitor '$db_monitor' does not exist in filesystem, should have been at ".$Storage->Path().'/'.$Monitor->Id()."\n" );
|
||||
#if ( confirm() )
|
||||
#{
|
||||
# We don't actually do this in case it's new
|
||||
#my $res = $deleteMonitorSth->execute( $db_monitor )
|
||||
# or Fatal( "Can't execute: ".$deleteMonitorSth->errstr() );
|
||||
#$cleaned = 1;
|
||||
#}
|
||||
}
|
||||
} # end foreach db_monitor
|
||||
if ( $cleaned ) {
|
||||
Debug("Have done some cleaning, restarting.");
|
||||
|
|
Loading…
Reference in New Issue