X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fupload_target.pm;h=33088cbd2d993366ee61962175b01fa98f9d069e;hb=7ff3a40dfb8e6d5cc15e87346f447b1d6806e39c;hp=f3486d393efd4d34c932f45ae92f1148a31f7ca8;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125;p=freeside.git diff --git a/FS/FS/upload_target.pm b/FS/FS/upload_target.pm index f3486d393..33088cbd2 100644 --- a/FS/FS/upload_target.pm +++ b/FS/FS/upload_target.pm @@ -153,7 +153,8 @@ sub put { local $@; my $connection = eval { $self->connect }; return $@ if $@; - $connection->put($localname, $remotename) or return $connection->error; + $connection->put($localname, $remotename); + return $connection->error || ''; } elsif ( $self->protocol eq 'email' ) { my $to = join('@', $self->username, $self->hostname); @@ -199,13 +200,15 @@ sub connect { eval "use Net::SFTP::Foreign;"; die $@ if $@; my %args = ( - port => $self->port, user => $self->username, - password => $self->password, - more => ($DEBUG ? '-v' : ''), timeout => 30, - autodie => 1, #we're doing this anyway + autodie => 0, #we're doing this anyway ); + # Net::SFTP::Foreign does not deal well with args that are defined + # but empty + $args{port} = $self->port if $self->port and $self->port != 22; + $args{password} = $self->password if length($self->password) > 0; + $args{more} = '-v' if $DEBUG; my $sftp = Net::SFTP::Foreign->new($self->hostname, %args); $sftp->setcwd($self->path); return $sftp;