Test for values in aws url and give better errors if Url empty. Don't append events dir to S3 bucket path

pull/2680/head
Isaac Connor 2019-08-07 15:47:12 -04:00
parent fb414b3f19
commit bf6170bf61
1 changed files with 54 additions and 48 deletions

View File

@ -573,7 +573,9 @@ sub CopyTo {
my $moved = 0;
if ( $$NewStorage{Type} eq 's3fs' ) {
if ( $$NewStorage{Url} ) {
my ( $aws_id, $aws_secret, $aws_host, $aws_bucket ) = ( $$NewStorage{Url} =~ /^\s*([^:]+):([^@]+)@([^\/]*)\/(.+)\s*$/ );
if ( $aws_id and $aws_secret and $aws_host and $aws_bucket ) {
eval {
require Net::Amazon::S3;
require File::Slurp;
@ -588,7 +590,7 @@ sub CopyTo {
die;
}
my $event_path = 'events/'.$self->RelativePath();
my $event_path = $self->RelativePath();
Debug("Making directory $event_path/");
if ( ! $bucket->add_key($event_path.'/', '') ) {
die "Unable to add key for $event_path/";
@ -596,7 +598,7 @@ sub CopyTo {
my @files = glob("$OldPath/*");
Debug("Files to move @files");
for my $file (@files) {
foreach my $file ( @files ) {
next if $file =~ /^\./;
( $file ) = ( $file =~ /^(.*)$/ ); # De-taint
my $starttime = [gettimeofday];
@ -621,7 +623,11 @@ sub CopyTo {
$moved = 1;
};
Error($@) if $@;
die $@ if $@;
} else {
Error("Unable to parse S3 Url into it's component parts.");
}
#die $@ if $@;
} # end if Url
} # end if s3
my $error = '';