Fixed issue with empty tar files.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2794 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2009-03-03 17:51:27 +00:00
parent f512cd91e7
commit 60a9f1d317
1 changed files with 12 additions and 5 deletions

View File

@ -709,18 +709,25 @@ sub uploadArchFile
my $filter = shift; my $filter = shift;
my $event = shift; my $event = shift;
if ( !ZM_UPLOAD_FTP_HOST )
{
Error( "Cannot upload archive as no FTP host defined" );
return( 0 );
}
my $arch_file = ZM_UPLOAD_FTP_LOC_DIR.'/'.$event->{MonitorName}.'-'.$event->{Id}; my $arch_file = ZM_UPLOAD_FTP_LOC_DIR.'/'.$event->{MonitorName}.'-'.$event->{Id};
my $arch_image_path = getEventPath( $event )."/".((ZM_UPLOAD_ARCH_ANALYSE)?'{*analyse,*capture}':'*capture').".jpg"; my $arch_image_path = getEventPath( $event )."/".((ZM_UPLOAD_ARCH_ANALYSE)?'{*analyse,*capture}':'*capture').".jpg";
my $arch_error; my @arch_image_files = glob($arch_image_path);
my $arch_error;
if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" ) if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" )
{ {
$arch_file .= '.zip'; $arch_file .= '.zip';
my $zip = Archive::Zip->new(); my $zip = Archive::Zip->new();
Info( "Creating upload file '$arch_file'\n" ); Info( "Creating upload file '$arch_file', ".int(@arch_image_files)." files\n" );
my $status = &AZ_OK; my $status = &AZ_OK;
foreach my $image_file ( <*$arch_image_path> ) foreach my $image_file ( @arch_image_files )
{ {
Info( "Adding $image_file\n" ); Info( "Adding $image_file\n" );
my $member = $zip->addFile( $image_file ); my $member = $zip->addFile( $image_file );
@ -744,9 +751,9 @@ sub uploadArchFile
{ {
$arch_file .= '.tar'; $arch_file .= '.tar';
} }
Info( "Creating upload file '$arch_file'\n" ); Info( "Creating upload file '$arch_file', ".int(@arch_image_files)." files\n" );
if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_COMPRESS, <*$arch_image_path> ) ) if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_COMPRESS, @arch_image_files ) )
{ {
Error( "Tar error: ".Archive::Tar->error()."\n " ); Error( "Tar error: ".Archive::Tar->error()."\n " );
} }