spacing. Add code to delete events that huse the deep storage scheme and have lost their symlinks.
This commit is contained in:
parent
fd72689182
commit
c285d5ebb1
|
@ -261,6 +261,7 @@ MAIN: while( $loop ) {
|
|||
next;
|
||||
}
|
||||
my @event_links = sort { $b <=> $a } grep { -l $_ } readdir( DIR );
|
||||
Debug("Have " . @event_links . ' event links');
|
||||
closedir(DIR);
|
||||
my $count = 0;
|
||||
foreach my $event_link ( @event_links ) {
|
||||
|
@ -292,6 +293,42 @@ MAIN: while( $loop ) {
|
|||
$Event->DiskSpace( undef );
|
||||
} # event path exists
|
||||
} # end foreach event_link
|
||||
|
||||
# Now check for events that have lost their link
|
||||
|
||||
my @time_dirs = glob('[0-9][0-9]/[0-9][0-9]/[0-9][0-9]');
|
||||
foreach my $event_dir ( @time_dirs ) {
|
||||
Debug("Checking time dir $event_dir");
|
||||
( $event_dir ) = ( $event_dir =~ /^(.*)$/ ); # De-taint
|
||||
|
||||
my $event_id = undef;
|
||||
|
||||
my @mp4_files = glob("$event_dir/[0-9]+\-video.mp4");
|
||||
foreach my $mp4_file ( @mp4_files ) {
|
||||
my ( $id ) = $mp4_file =~ /^([0-9]+)\-video\.mp4$/;
|
||||
if ( $id ) {
|
||||
$event_id = $id;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if ( $event_id ) {
|
||||
my $Event = $fs_events->{$event_id} = new ZoneMinder::Event();
|
||||
$$Event{Id} = $event_id;
|
||||
$$Event{Path} = join('/', $Storage->Path(), $day_dir, $event_dir);
|
||||
$$Event{RelativePath} = join('/', $day_dir, $event_dir);
|
||||
$$Event{Scheme} = 'Deep';
|
||||
$Event->MonitorId( $monitor_dir );
|
||||
$Event->StorageId( $Storage->Id() );
|
||||
$Event->DiskSpace( undef );
|
||||
} else {
|
||||
aud_print("Deleting event directories with no event id information at $day_dir/$event_dir");
|
||||
if ( confirm() ) {
|
||||
my $command = "rm -rf $event_dir";
|
||||
executeShellCommand( $command );
|
||||
$cleaned = 1;
|
||||
}
|
||||
} # end if able to find id
|
||||
} # end foreach event_dir without link
|
||||
chdir( $Storage->Path() );
|
||||
} # end foreach day dir
|
||||
}
|
||||
|
@ -701,17 +738,18 @@ FROM Frames WHERE EventId=?';
|
|||
if ( $Config{ZM_LOG_DATABASE_LIMIT} =~ /^(.*)s$/ ) {
|
||||
$Config{ZM_LOG_DATABASE_LIMIT} = $1;
|
||||
}
|
||||
my $deleted_rows;
|
||||
do {
|
||||
my $deleteLogByTimeSql =
|
||||
'DELETE low_priority FROM Logs
|
||||
WHERE TimeKey < unix_timestamp(now() - interval '.$Config{ZM_LOG_DATABASE_LIMIT}.')';
|
||||
'DELETE FROM Logs
|
||||
WHERE TimeKey < unix_timestamp(now() - interval '.$Config{ZM_LOG_DATABASE_LIMIT}.') LIMIT 10';
|
||||
my $deleteLogByTimeSth = $dbh->prepare_cached( $deleteLogByTimeSql )
|
||||
or Fatal( "Can't prepare '$deleteLogByTimeSql': ".$dbh->errstr() );
|
||||
$res = $deleteLogByTimeSth->execute()
|
||||
or Fatal( "Can't execute: ".$deleteLogByTimeSth->errstr() );
|
||||
if ( $deleteLogByTimeSth->rows() ){
|
||||
aud_print( 'Deleted '.$deleteLogByTimeSth->rows()
|
||||
." log table entries by time\n" );
|
||||
}
|
||||
$deleted_rows = $deleteLogByTimeSth->rows();
|
||||
aud_print( "Deleted $deleted_rows log table entries by time\n" );
|
||||
} while ( $deleted_rows );
|
||||
}
|
||||
} # end if ZM_LOG_DATABASE_LIMIT
|
||||
$loop = $continuous;
|
||||
|
|
Loading…
Reference in New Issue