- various fixes to configure.pl and lib/BackupPC/Lib.pm
[BackupPC.git] / lib / BackupPC / Xfer / RsyncFileIO.pm
index ef736e1..2829e79 100644 (file)
@@ -12,7 +12,7 @@
 #
 #========================================================================
 #
-# Version 2.1.0, released 20 Jun 2004.
+# Version 3.0.0alpha, released 23 Jan 2006.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -61,7 +61,7 @@ sub new
     my $fio = bless {
         blockSize    => 700,
         logLevel     => 0,
-        digest       => File::RsyncP::Digest->new($options->{protocol_version}),
+        digest       => File::RsyncP::Digest->new(),
         checksumSeed => 0,
        attrib       => {},
        logHandler   => \&logHandler,
@@ -76,6 +76,7 @@ sub new
        %$options,
     }, $class;
 
+    $fio->{digest}->protocol($fio->{protocol_version});
     $fio->{shareM}   = $fio->{bpc}->fileNameEltMangle($fio->{share});
     $fio->{outDir}   = "$fio->{xfer}{outDir}/new/";
     $fio->{outDirSh} = "$fio->{outDir}/$fio->{shareM}/";
@@ -474,6 +475,11 @@ sub attribWrite
     my($fio, $d) = @_;
     my($poolWrite);
 
+    #
+    # Don't write attributes on 2nd phase - they're already
+    # taken care of during the first phase.
+    #
+    return if ( $fio->{phase} > 0 );
     if ( !defined($d) ) {
         #
         # flush all entries (in reverse order)
@@ -517,7 +523,8 @@ sub attribWrite
                        $fio->logFileAction("skip", {
                                    %{$fio->{viewCache}{$d}{$f}},
                                    name => $name,
-                               }) if ( $fio->{logLevel} >= 2 );
+                               }) if ( $fio->{logLevel} >= 2
+                                      && $a->{type} == BPC_FTYPE_FILE );
                    }
                } elsif ( !$fio->{full} ) {
                    ##print("Delete file $f\n");
@@ -736,23 +743,23 @@ sub logFileAction
     my $owner = "$f->{uid}/$f->{gid}";
     my $type  = (("", "p", "c", "", "d", "", "b", "", "", "", "l", "", "s"))
                    [($f->{mode} & S_IFMT) >> 12];
-    my $link;
+    my $name = $f->{name};
 
     if ( ($f->{mode} & S_IFMT) == S_IFLNK ) {
-        $link = " -> $f->{link}";
-    } if ( ($f->{mode} & S_IFMT) == S_IFREG
+        $name .= " -> $f->{link}";
+    } elsif ( ($f->{mode} & S_IFMT) == S_IFREG
             && defined($f->{hlink}) && !$f->{hlink_self} ) {
-        $link = " -> $f->{hlink}";
+        $name .= " -> $f->{hlink}";
     }
+    $name =~ s/\n/\\n/g;
 
-    $fio->log(sprintf("  %-6s %1s%4o %9s %11.0f %s%s",
+    $fio->log(sprintf("  %-6s %1s%4o %9s %11.0f %s",
                                $action,
                                $type,
                                $f->{mode} & 07777,
                                $owner,
                                $f->{size},
-                               $f->{name},
-                                $link));
+                                $name));
 }
 
 #
@@ -883,7 +890,8 @@ sub fileDeltaRxNext
                         if ( $fio->{logLevel} >= 9 );
         $fio->{rxOutFile} = $rxOutFile;
         $fio->{rxOutFileRel} = $rxOutFileRel;
-        $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version});
+        $fio->{rxDigest} = File::RsyncP::Digest->new();
+        $fio->{rxDigest}->protocol($fio->{protocol_version});
         $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed}));
     }
     if ( defined($fio->{rxMatchBlk})
@@ -1041,6 +1049,7 @@ sub fileDeltaRxDone
 
     close($fio->{rxInFd})  if ( defined($fio->{rxInFd}) );
     unlink("$fio->{outDirSh}RStmp") if  ( -f "$fio->{outDirSh}RStmp" );
+    $fio->{phase} = $phase;
 
     #
     # Check the final md4 digest
@@ -1080,7 +1089,8 @@ sub fileDeltaRxDone
                #
                # Empty file; just create an empty file digest
                #
-               $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version});
+               $fio->{rxDigest} = File::RsyncP::Digest->new();
+                $fio->{rxDigest}->protocol($fio->{protocol_version});
                $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed}));
                $newDigest = $fio->{rxDigest}->digest;
            }