* The CSS definition has been removed from the config.pl file and
[BackupPC.git] / lib / BackupPC / Xfer / Tar.pm
index f8f22dc..1de40ff 100644 (file)
@@ -29,7 +29,7 @@
 #
 #========================================================================
 #
 #
 #========================================================================
 #
-# Version 2.1.0_CVS, released 3 Jul 2003.
+# Version 2.1.0beta0, released 20 Mar 2004.
 #
 # See http://backuppc.sourceforge.net.
 #
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -189,6 +189,7 @@ sub start
         #
         # Run the tar command
         #
         #
         # Run the tar command
         #
+       alarm(0);
        $bpc->cmdExecOrEval($tarClientCmd, $args);
         # should not be reached, but just in case...
         $t->{_errStr} = "Can't exec @$tarClientCmd";
        $bpc->cmdExecOrEval($tarClientCmd, $args);
         # should not be reached, but just in case...
         $t->{_errStr} = "Can't exec @$tarClientCmd";
@@ -221,17 +222,19 @@ sub readOutput
     while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
         $_ = $1;
         $t->{tarOut} = $2;
     while ( $t->{tarOut} =~ /(.*?)[\n\r]+(.*)/s ) {
         $_ = $1;
         $t->{tarOut} = $2;
-        $t->{XferLOG}->write(\"$_\n");
         #
         # refresh our inactivity alarm
         #
         #
         # refresh our inactivity alarm
         #
-        alarm($conf->{ClientTimeout});
+        alarm($conf->{ClientTimeout}) if ( !$t->{abort} );
         $t->{lastOutputLine} = $_ if ( !/^$/ );
         if ( /^Total bytes written: / ) {
         $t->{lastOutputLine} = $_ if ( !/^$/ );
         if ( /^Total bytes written: / ) {
+            $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
             $t->{xferOK} = 1;
         } elsif ( /^\./ ) {
             $t->{xferOK} = 1;
         } elsif ( /^\./ ) {
+            $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
             $t->{fileCnt}++;
         } else {
             $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
             $t->{xferErrCnt}++;
            #
            # If tar encounters a minor error, it will exit with a non-zero
@@ -240,11 +243,34 @@ sub readOutput
            #
            $t->{tarBadExitOk} = 1
                    if ( $t->{xferOK} && /Error exit delayed from previous / );
            #
            $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;
 }
 
        }
     }
     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) = @_;
 sub setSelectMask
 {
     my($t, $FDreadRef) = @_;