- if ( !link("$Dir/$Backups[$j]{num}/$file",
- "$Dir/$num/$shareM/$fileM") ) {
- my $str = \"Unable to link $num/$f->{share}/$f->{file} to"
- . " $Backups[$j]{num}/$f->{share}/$f->{file}\n";
- $XferLOG->write(\$str);
+
+ my($exists, $digest, $origSize, $outSize, $errs)
+ = BackupPC::PoolWrite::LinkOrCopy(
+ $bpc,
+ "$Dir/$Backups[$j]{num}/$file",
+ $Backups[$j]{compress},
+ "$Dir/$num/$shareM/$fileM",
+ $Conf{CompressLevel});
+ if ( !$exists ) {
+ #
+ # the hard link failed, most likely because the target
+ # file has too many links. We have copied the file
+ # instead, so add this to the new file list.
+ #
+ if ( !defined($newFilesFH) ) {
+ my $str = "Appending to NewFileList for $shareM/$fileM\n";
+ $XferLOG->write(\$str);
+ open($newFilesFH, ">>", "$TopDir/pc/$client/NewFileList")
+ || die("can't open $TopDir/pc/$client/NewFileList");
+ binmode($newFilesFH);
+ }
+ if ( -f "$Dir/$num/$shareM/$fileM" ) {
+ print($newFilesFH "$digest $origSize $shareM/$fileM\n");
+ } else {
+ my $str = "Unable to link/copy $num/$f->{share}/$f->{file}"
+ . " to $Backups[$j]{num}/$f->{share}/$f->{file}\n";
+ $XferLOG->write(\$str);
+ }