From d8fb191dd5526a895b681416080d66615f1a6228 Mon Sep 17 00:00:00 2001 From: Paul C Mantz Date: Thu, 27 Aug 2009 23:47:42 -0500 Subject: [PATCH] eval errors handled correctly in BackupPC::Xfer::Ftp --- lib/BackupPC/Xfer/Ftp.pm | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/BackupPC/Xfer/Ftp.pm b/lib/BackupPC/Xfer/Ftp.pm index 91f1881..d009eb7 100644 --- a/lib/BackupPC/Xfer/Ftp.pm +++ b/lib/BackupPC/Xfer/Ftp.pm @@ -187,7 +187,7 @@ sub start : Net::FTP->new(%$args); }; if ($@) { - $t->{_errStr} = "Can't open connection to $args->{host}: $!"; + $t->{_errStr} = "Can't open connection to $args->{Host}: $@"; $t->{xferErrCnt}++; return; } @@ -197,8 +197,8 @@ sub start # undef $@; eval { $t->{ftp}->login( $conf->{FtpUserName}, $conf->{FtpPasswd} ); }; - if ( $@ ) { - $t->{_errStr} = "Can't login to $args->{host}: $!"; + if ($@) { + $t->{_errStr} = "Can't login to $args->{Host}: $@"; $t->{xferErrCnt}++; return; } @@ -207,7 +207,7 @@ sub start eval { $t->{ftp}->binary(); }; if ($@) { $t->{_errStr} = - "Can't enable binary transfer mode to $args->{host}: $!"; + "Can't enable binary transfer mode to $args->{Host}: $@"; $t->{xferErrCnt}++; return; } @@ -215,8 +215,7 @@ sub start undef $@; eval { $t->{shareName} =~ m/^\.?$/ || $t->{ftp}->cwd( $t->{shareName} ); }; if ($@) { - $t->{_errStr} = - "Can't change working directory to $t->{shareName}: $!"; + $t->{_errStr} = "Can't change working directory to $t->{shareName}: $@"; $t->{xferErrCnt}++; return; } @@ -225,7 +224,7 @@ sub start eval { $t->{sharePath} = $t->{ftp}->pwd(); }; if ($@) { $t->{_errStr} = - "Can't retrieve full working directory of $t->{shareName}: $!"; + "Can't retrieve full working directory of $t->{shareName}: $@"; $t->{xferErrCnt}++; return; } @@ -575,7 +574,7 @@ sub remotels }; if ($@) { $t->{xferErrCnt}++; - return "can't retrieve remote directory contents of $path: $!"; + return "can't retrieve remote directory contents of $path: $@"; } foreach my $info ( @{parse_dir($dirContents)} ) { @@ -750,13 +749,11 @@ sub handleDir unless ( -d $OutDir ) { + undef $@; eval { mkpath( $OutDir, 0, 0755 ) }; - if ( $@ ) { - $t->logFileAction( "fail", $dir->{utf8name}, $dir ); - return; - } else { - $t->logFileAction( "create", $dir->{utf8name}, $dir ); - } + $t->logFileAction( defined $@ ? "fail" : "create", + $dir->{utf8name}, $dir ); + return if defined $@; } $attrib = BackupPC::Attrib->new( { compress => $t->{compress} } ); -- 1.6.0.4