From 493a2386c4a78d854fa06339c3f80597288006c9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 22 Jan 2018 11:09:35 -0500 Subject: [PATCH] Only load Time from StartTime if it has a value. Parse Path to get LInkPath if no Time. --- scripts/ZoneMinder/lib/ZoneMinder/Event.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 957488d9e..4c9d85f75 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -90,8 +90,9 @@ sub Time { $_[0]{Time} = $_[1]; } if ( ! defined $_[0]{Time} ) { - - $_[0]{Time} = Date::Parse::str2time( $_[0]{StartTime} ); + if ( $_[0]{StartTime} ) { + $_[0]{Time} = Date::Parse::str2time( $_[0]{StartTime} ); + } } return $_[0]{Time}; } @@ -230,8 +231,15 @@ sub LinkPath { ), '.'.$$event{Id} ); + } elsif ( $$event{Path} ) { + if ( ( $$event{Path} =~ /^(\d+\/\d{4}\/\d{2}\/\d{2})/ ) ) { + $$event{LinkPath} = $1.'/.'.$$event{Id}; + } else { + Error("Unable to get LinkPath from Path for $$event{Id} $$event{Path}"); + $$event{LinkPath} = ''; + } } else { - Error("Event $$event{Id} has no value for Time(), unable to determine link path"); + Error("Event $$event{Id} $$event{Path} has no value for Time(), unable to determine link path"); $$event{LinkPath} = ''; } } # end if Scheme @@ -243,7 +251,7 @@ sub LinkPath { sub GenerateVideo { my ( $self, $rate, $fps, $scale, $size, $overwrite, $format ) = @_; - my $event_path = $self->getPath( ); + my $event_path = $self->Path( ); chdir( $event_path ); ( my $video_name = $self->{Name} ) =~ s/\s/_/g;