From d1e08d888f564cd66a29c6ae384f9c3b928309e7 Mon Sep 17 00:00:00 2001 From: stan Date: Fri, 3 Jan 2003 14:41:04 +0000 Subject: [PATCH] Remove old WAP image files. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@231 e3e1d417-86f3-4887-817a-d78f3d33393f --- scripts/zmaudit.pl.z | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/zmaudit.pl.z b/scripts/zmaudit.pl.z index 4cf2260b8..e99340725 100755 --- a/scripts/zmaudit.pl.z +++ b/scripts/zmaudit.pl.z @@ -38,6 +38,7 @@ use constant DB_NAME => "zm"; use constant DB_USER => "zmadmin"; use constant DB_PASS => "zmadminzm"; +use constant IMAGE_PATH => "@WEB_PREFIX@"; use constant EVENT_PATH => "@WEB_PREFIX@/events"; use constant LOG_FILE => '/tmp/zmaudit.log'; @@ -138,6 +139,8 @@ if ( $delay ) # Background mode select( STDERR ); $| = 1; select( LOG ); $| = 1; } +my $max_image_age = 15/(24*60); # 15 Minutes +my $image_path = IMAGE_PATH; do { my $fs_monitors; @@ -269,6 +272,16 @@ do $res = $sth6->execute( $stat->{EventId} ) or die( "Can't execute: ".$sth8->errstr() ); } } + + # Now delete any old wap image files + if ( my @old_files = grep { -M > $max_image_age } <$image_path/*-wap-*.{jpg,gif,wbmp}> ) + { + print( "Deleting ".int(@old_files)." old wap images\n" ); + my $untainted_old_files = join( ";", @old_files ); + ( $untainted_old_files ) = ( $untainted_old_files =~ /^(.*)$/ ); + unlink( split( ";", $untainted_old_files ) ); + } + sleep( $delay ) if ( $delay ); } while( $delay ); if ( !$yes && !$report )