X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FXfer%2FTar.pm;h=bc4f787193db4c055e9cc4add8dc60a8b7819d95;hp=f8f22dce39da1ef3f1ccbcefa32d6f29488387a4;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=5729095faa3ef12dc5d4f02538c3650ac81912ef diff --git a/lib/BackupPC/Xfer/Tar.pm b/lib/BackupPC/Xfer/Tar.pm index f8f22dc..bc4f787 100644 --- a/lib/BackupPC/Xfer/Tar.pm +++ b/lib/BackupPC/Xfer/Tar.pm @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 3 Jul 2003. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # @@ -92,24 +92,11 @@ sub start } else { # # Turn $conf->{BackupFilesOnly} and $conf->{BackupFilesExclude} - # into a hash of arrays of files + # into a hash of arrays of files, and $conf->{TarShareName} + # to an array # - $conf->{TarShareName} = [ $conf->{TarShareName} ] - unless ref($conf->{TarShareName}) eq "ARRAY"; - foreach my $param qw(BackupFilesOnly BackupFilesExclude) { - next if ( !defined($conf->{$param}) ); - if ( ref($conf->{$param}) eq "ARRAY" ) { - $conf->{$param} = { - $conf->{TarShareName}[0] => $conf->{$param} - }; - } elsif ( ref($conf->{$param}) eq "HASH" ) { - # do nothing - } else { - $conf->{$param} = { - $conf->{TarShareName}[0] => [ $conf->{$param} ] - }; - } - } + $bpc->backupFileConfFix($conf, "TarShareName"); + if ( defined($conf->{BackupFilesExclude}{$t->{shareName}}) ) { foreach my $file ( @{$conf->{BackupFilesExclude}{$t->{shareName}}} ) { @@ -189,6 +176,7 @@ sub start # # Run the tar command # + alarm(0); $bpc->cmdExecOrEval($tarClientCmd, $args); # should not be reached, but just in case... $t->{_errStr} = "Can't exec @$tarClientCmd"; @@ -221,17 +209,19 @@ sub readOutput while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) { $_ = $1; $t->{tarOut} = $2; - $t->{XferLOG}->write(\"$_\n"); # # refresh our inactivity alarm # - alarm($conf->{ClientTimeout}); + alarm($conf->{ClientTimeout}) if ( !$t->{abort} ); $t->{lastOutputLine} = $_ if ( !/^$/ ); if ( /^Total bytes written: / ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 ); $t->{xferOK} = 1; } elsif ( /^\./ ) { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 ); $t->{fileCnt}++; } else { + $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 ); $t->{xferErrCnt}++; # # If tar encounters a minor error, it will exit with a non-zero @@ -240,11 +230,34 @@ sub readOutput # $t->{tarBadExitOk} = 1 if ( $t->{xferOK} && /Error exit delayed from previous / ); + # + # Also remember files that had read errors + # + if ( /: \.\/(.*): Read error at byte / ) { + my $badFile = $1; + push(@{$t->{badFiles}}, { + share => $t->{shareName}, + file => $badFile + }); + } + } } return 1; } +sub abort +{ + my($t, $reason) = @_; + my @xferPid = $t->xferPid; + + $t->{abort} = 1; + $t->{abortReason} = $reason; + if ( @xferPid ) { + kill($t->{bpc}->sigName2num("INT"), @xferPid); + } +} + sub setSelectMask { my($t, $FDreadRef) = @_;