Better logging, test for path existence before DiskSpace update. Fix delete_files when moving
This commit is contained in:
parent
80f0515eae
commit
5db4180327
|
@ -367,11 +367,11 @@ sub delete_files {
|
||||||
Error("No monitor id assigned to event $$event{Id}");
|
Error("No monitor id assigned to event $$event{Id}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $event_path = $event->Path();
|
my $event_path = $event->RelativePath();
|
||||||
Debug("Deleting files for Event $$event{Id} from $event_path.");
|
Debug("Deleting files for Event $$event{Id} from $storage_path/$event_path.");
|
||||||
if ( $event_path ) {
|
if ( $event_path ) {
|
||||||
( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
|
#( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
|
||||||
my $command = "/bin/rm -rf $event_path";
|
my $command = "/bin/rm -rf $storage_path/$event_path";
|
||||||
ZoneMinder::General::executeShellCommand( $command );
|
ZoneMinder::General::executeShellCommand( $command );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,9 +395,13 @@ sub Storage {
|
||||||
sub check_for_in_filesystem {
|
sub check_for_in_filesystem {
|
||||||
my $path = $_[0]->Path();
|
my $path = $_[0]->Path();
|
||||||
if ( $path ) {
|
if ( $path ) {
|
||||||
my @files = glob( $path . '/*' );
|
if ( -e $path ) {
|
||||||
|
my @files = glob "$path/*";
|
||||||
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files");
|
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files");
|
||||||
return 1 if @files;
|
return 1 if @files;
|
||||||
|
} else {
|
||||||
|
Warning("Path not found for Event $_[0]{Id} at $path");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found no files");
|
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found no files");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -421,11 +425,15 @@ sub DiskSpace {
|
||||||
$_[0]{DiskSpace} = $_[1];
|
$_[0]{DiskSpace} = $_[1];
|
||||||
}
|
}
|
||||||
if ( ! defined $_[0]{DiskSpace} ) {
|
if ( ! defined $_[0]{DiskSpace} ) {
|
||||||
|
if ( -e $_[0]->Path() ) {
|
||||||
my $size = 0;
|
my $size = 0;
|
||||||
File::Find::find( { wanted=>sub { $size += -f $_ ? -s _ : 0 }, untaint=>1 }, $_[0]->Path() );
|
File::Find::find( { wanted=>sub { $size += -f $_ ? -s _ : 0 }, untaint=>1 }, $_[0]->Path() );
|
||||||
$_[0]{DiskSpace} = $size;
|
$_[0]{DiskSpace} = $size;
|
||||||
Debug("DiskSpace for event $_[0]{Id} at $_[0]{Path} Updated to $size bytes");
|
Debug("DiskSpace for event $_[0]{Id} at $_[0]{Path} Updated to $size bytes");
|
||||||
|
} else {
|
||||||
|
Warning("Event does not exist at $_[0]{Path}");
|
||||||
}
|
}
|
||||||
|
} # end if ! defined DiskSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
sub MoveTo {
|
sub MoveTo {
|
||||||
|
|
Loading…
Reference in New Issue