blib/lib/File/RsyncP/FileIO.pm

filter: Statementstmt 12.4% 41 / 329 Branchbran 0.0% 0 / 178 Conditioncond 0.0% 0 / 59 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 28.8% 13 / 45 Podpod 80.6% 25 / 31 totaltotal 11.7% 79 / 675 CC 112 SCAR 53.8
CC
112
Cov
7%
fileDeltaRxNext
756.0
fileDeltaRxDone
462.0
attribSet
132.0
CRAP 216.8
« blib/lib/File/RsyncP.pm ↑ Summary blib/lib/File/RsyncP/Digest.pm »
1 #============================================================= -*-perl-*-
2 #
3 # File::RsyncP::FileIO package
4 #
5 # DESCRIPTION
6 # Provide file system IO for File::RsyncP.
7 #
8 # AUTHOR
9 # Craig Barratt <cbarratt@users.sourceforge.net>
10 #
11 # COPYRIGHT
12 # File::RsyncP is Copyright (C) 2002 Craig Barratt.
13 #
14 # Rsync is Copyright (C) 1996-2001 by Andrew Tridgell, 1996 by Paul
15 # Mackerras, and 2001, 2002 by Martin Pool.
16 #
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #
31 #========================================================================
32 #
33 # Version 0.72, released 11 Jan 2015.
34 #
35 # See http://perlrsync.sourceforge.net.
36 #
37 #========================================================================
38  
39 package File::RsyncP::FileIO;
40  
41 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use File::RsyncP::Digest;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
47 1 $VERSION = '0.72';
48  
49 1 ▶use constant S_IFMT => 0170000; # type of file
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶use constant S_IFDIR => 0040000; # directory
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use constant S_IFCHR => 0020000; # character special
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use constant S_IFBLK => 0060000; # block special
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use constant S_IFREG => 0100000; # regular
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use constant S_IFLNK => 0120000; # symbolic link
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use constant S_IFSOCK => 0140000; # socket
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 ▶use constant S_IFIFO => 0010000; # fifo
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 sub new
59 {
60 0 ▶ my($class, $options) = @_;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
61  
62 0 ▶ $options ||= {};
Condition0%0/2
$options ||= {}
l!l
00
MC/DC0%0/1
$options ||= {}
$options
Truth table0%0/2
A
A= $options
Aresult
11
00
63 my $self = bless {
64 blockSize => 700,
65 logLevel => 0,
66 0 digest => File::RsyncP::Digest->new($options->{protocol_version}),
67 checksumSeed => 0,
68 logHandler => \&logHandler,
69 %$options,
70 }, $class;
71 0 return $self;
72 }
73  
74 sub blockSize
75 {
76 0 ▶ my($fio, $value) = @_;
Subroutine blockSize: not called CC=2 SCAR=17.9
Pod documented
77  
78 0 ▶ $fio->{blockSize} = $value if ( defined($value) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
79 0 return $fio->{blockSize};
80 }
81  
82 #
83 # We publish our version to File::RsyncP. This is so File::RsyncP
84 # can provide backward compatibility to older FileIO code.
85 #
86 # Versions:
87 #
88 # undef or 1: protocol version 26, no hardlinks
89 # 2: protocol version 28, supports hardlinks
90 #
91 sub version
92 {
93 0 ▶ return 2;
Subroutine version: not called CC=1 SCAR=6.9
Pod undocumented
94 }
95  
96 sub preserve_hard_links
97 {
98 0 ▶ my($fio, $value) = @_;
Subroutine preserve_hard_links: not called CC=2 SCAR=17.9
Pod undocumented
99  
100 0 ▶ $fio->{preserve_hard_links} = $value if ( defined($value) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
101 0 return $fio->{preserve_hard_links};
102 }
103  
104 sub protocol_version
105 {
106 0 ▶ my($fio, $value) = @_;
Subroutine protocol_version: not called CC=2 SCAR=17.9
Pod undocumented
107  
108 0 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
109 0 $fio->{protocol_version} = $value;
110 0 $fio->{digest}->protocol($fio->{protocol_version});
111 }
112 0 return $fio->{protocol_version};
113 }
114  
115 sub logHandlerSet
116 {
117 0 ▶ my($fio, $sub) = @_;
Subroutine logHandlerSet: not called CC=1 SCAR=6.9
Pod documented
118 0 $fio->{logHandler} = $sub;
119 }
120  
121 #
122 # Given a remote name, return the local name
123 #
124 sub localName
125 {
126 0 ▶ my($fio, $name) = @_;
Subroutine localName: not called CC=4 SCAR=30.0
Pod undocumented
127  
128 return $name if ( !defined($fio->{localDir})
129 0 ▶ && !defined($fio->{remoteDir}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fio->{"localDir"} or defined $fio->{"remoteDir"} 0 0 0
Condition0%0/3
defined $fio->{"localDir"} or defined $fio->{"remoteDir"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $fio->{"localDir"} or defined $fio->{"remoteDir"}
defined $fio->{"localDir"} defined $fio->{"remoteDir"}
Truth table0%0/3
A or B
A= defined $fio->{"localDir"}B= defined $fio->{"remoteDir"}
ABresult
1X1
011
000
130 0 ▶ if ( substr($name, 0, length($fio->{remoteDir})) eq $fio->{remoteDir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($name, 0, length $fio->{"remoteDir"}) eq $fio->{"remoteDir"}) 0 0 0
131 0 substr($name, 0, length($fio->{remoteDir})) = $fio->{localDir};
132 }
133 0 return $name;
134 }
135  
136 #
137 # Setup rsync checksum computation for the given file.
138 #
139 sub csumStart
140 {
141 0 ▶ my($fio, $f, $needMD4) = @_;
Subroutine csumStart: not called CC=6 SCAR=37.4
Pod documented
142 0 local(*F);
143 0 my $localName = $fio->localName($f->{name});
144  
145 0 $fio->{file} = $f;
146 0 ▶ $fio->csumEnd if ( defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"fh"} 0 0 0
147 0 ▶ return if ( !-f $localName || -l $localName );
Branch: 1 branch
BranchTrueFalseTotal
if not -f $localName or -l $localName 0 0 0
Condition0%0/3
not -f $localName or -l $localName
l!l&&r!l&&!r
000
MC/DC0%0/2
not -f $localName or -l $localName
not -f $localName -l $localName
Truth table0%0/3
not(A) or B
A= not -f $localNameB= -l $localName
ABresult
1X1
011
000
148 0 ▶ if ( !open(F, $localName) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, $localName) 0 0 0
149 0 $fio->log("Can't open $localName");
150 0 return -1;
151 }
152 0 ▶ if ( $needMD4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($needMD4) { } 0 0 0
153 $fio->{csumDigest}
154 0 = File::RsyncP::Digest->new($fio->{protocol_version});
155 0 $fio->{csumDigest}->add(pack("V", $fio->{checksumSeed}));
156 } else {
157 0 delete($fio->{csumDigest});
158 }
159 0 $fio->{fh} = *F;
160 }
161  
162 sub csumGet
163 {
164 0 ▶ my($fio, $num, $csumLen, $blockSize) = @_;
Subroutine csumGet: not called CC=7 SCAR=40.3
Pod documented
165 0 my($fileData);
166  
167 0 ▶ $num ||= 100;
Condition0%0/2
$num ||= 100
l!l
00
MC/DC0%0/1
$num ||= 100
$num
Truth table0%0/2
A
A= $num
Aresult
11
00
168 0 ▶ $csumLen ||= 16;
Condition0%0/2
$csumLen ||= 16
l!l
00
MC/DC0%0/1
$csumLen ||= 16
$csumLen
Truth table0%0/2
A
A= $csumLen
Aresult
11
00
169  
170 0 ▶ return if ( !defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fio->{"fh"} 0 0 0
171 0 ▶ if ( sysread($fio->{fh}, $fileData, $blockSize * $num) <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread($fio->{"fh"}, $fileData, $blockSize * $num) <= 0) 0 0 0
172 0 return;
173 }
174 0 ▶ $fio->{csumDigest}->add($fileData) if ( defined($fio->{csumDigest}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"csumDigest"} 0 0 0
175 $fio->log(sprintf("%s: getting csum ($num,$csumLen,%d,0x%x)",
176 $fio->{file}{name},
177 length($fileData),
178 $fio->{checksumSeed}))
179 0 ▶ if ( $fio->{logLevel} >= 10 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 10 0 0 0
180 return $fio->{digest}->blockDigest($fileData, $blockSize,
181 0 $csumLen, $fio->{checksumSeed});
182 }
183  
184 sub csumEnd
185 {
186 0 ▶ my($fio) = @_;
Subroutine csumEnd: not called CC=5 SCAR=34.0
Pod documented
187  
188 0 ▶ return if ( !defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fio->{"fh"} 0 0 0
189 #
190 # make sure we read the entire file for the file MD4 digest
191 #
192 0 ▶ if ( defined($fio->{csumDigest}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fio->{"csumDigest"}) 0 0 0
193 0 ▶ while ( sysread($fio->{fh}, my $fileData, 65536) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread($fio->{"fh"}, my $fileData, 65536) > 0) 0 0 0
194 0 $fio->{csumDigest}->add($fileData);
195 }
196 }
197 0 close($fio->{fh});
198 0 delete($fio->{fh});
199 0 ▶ return $fio->{csumDigest}->digest if ( defined($fio->{csumDigest}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"csumDigest"} 0 0 0
200 }
201  
202 sub readStart
203 {
204 0 ▶ my($fio, $f) = @_;
Subroutine readStart: not called CC=5 SCAR=34.0
Pod documented
205 0 local(*F);
206 0 my $localName = $fio->localName($f->{name});
207  
208 0 $fio->{file} = $f;
209 0 ▶ $fio->readEnd if ( defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"fh"} 0 0 0
210 0 ▶ return if ( !-f $localName || -l $localName );
Branch: 1 branch
BranchTrueFalseTotal
if not -f $localName or -l $localName 0 0 0
Condition0%0/3
not -f $localName or -l $localName
l!l&&r!l&&!r
000
MC/DC0%0/2
not -f $localName or -l $localName
not -f $localName -l $localName
Truth table0%0/3
not(A) or B
A= not -f $localNameB= -l $localName
ABresult
1X1
011
000
211 0 ▶ if ( !open(F, $localName) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, $localName) 0 0 0
212 0 $fio->log("Can't open $localName");
213 0 return;
214 }
215 0 $fio->{fh} = *F;
216 }
217  
218 sub read
219 {
220 0 ▶ my($fio, $num) = @_;
Subroutine read: not called CC=4 SCAR=30.0
Pod documented
221 0 my($fileData);
222  
223 0 ▶ $num ||= 32768;
Condition0%0/2
$num ||= 32768
l!l
00
MC/DC0%0/1
$num ||= 32768
$num
Truth table0%0/2
A
A= $num
Aresult
11
00
224 0 ▶ return if ( !defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fio->{"fh"} 0 0 0
225 0 ▶ if ( sysread($fio->{fh}, $fileData, $num) <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread($fio->{"fh"}, $fileData, $num) <= 0) 0 0 0
226 0 return $fio->readEnd;
227 }
228 0 return \$fileData;
229 }
230  
231 sub readEnd
232 {
233 0 ▶ my($fio) = @_;
Subroutine readEnd: not called CC=2 SCAR=17.9
Pod documented
234  
235 0 ▶ return if ( !defined($fio->{fh}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fio->{"fh"} 0 0 0
236 0 close($fio->{fh});
237 0 delete($fio->{fh});
238 }
239  
240 sub checksumSeed
241 {
242 0 ▶ my($fio, $checksumSeed) = @_;
Subroutine checksumSeed: not called CC=1 SCAR=6.9
Pod documented
243  
244 0 $fio->{checksumSeed} = $checksumSeed;
245 }
246  
247 sub dirs
248 {
249 0 ▶ my($fio, $localDir, $remoteDir) = @_;
Subroutine dirs: not called CC=1 SCAR=6.9
Pod documented
250  
251 0 $fio->{localDir} = $localDir;
252 0 $fio->{remoteDir} = $remoteDir;
253 }
254  
255 sub attribGet
256 {
257 0 ▶ my($fio, $f) = @_;
Subroutine attribGet: not called CC=2 SCAR=17.9
Pod documented
258 0 my $localName = $fio->localName($f->{name});
259  
260 0 my @s = stat($localName);
261 0 ▶ return if ( !@s );
Branch: 1 branch
BranchTrueFalseTotal
unless @s 0 0 0
262 return {
263 0 mode => $s[2],
264 uid => $s[4],
265 gid => $s[5],
266 size => $s[7],
267 mtime => $s[9],
268 }
269 }
270  
271 #
272 # Set the attributes for a file. Returns non-zero on error.
273 #
274 sub attribSet
275 {
276 0 ▶ my($fio, $f, $placeHolder) = @_;
Subroutine attribSet: not called CC=11 SCAR=48.8
Pod documented
277 0 my $ret;
278  
279 #
280 # Ignore placeholder attribute sets: only do real ones.
281 #
282 0 ▶ return if ( $placeHolder );
Branch: 1 branch
BranchTrueFalseTotal
if $placeHolder 0 0 0
283  
284 0 my $lName = $fio->localName($f->{name});
285 0 my @s = stat($lName);
286 0 my $a = {
287 mode => $s[2],
288 uid => $s[4],
289 gid => $s[5],
290 size => $s[7],
291 atime => $s[8],
292 mtime => $s[9],
293 };
294 0 ▶ $f->{atime} = $f->{mtime} if ( !defined($f->{atime}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f->{"atime"} 0 0 0
295 0 ▶ if ( ($f->{mode} & ~S_IFMT) != ($a->{mode} & ~S_IFMT)
Branch: 1 branch
BranchTrueFalseTotal
if (($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') and not chmod($f->{"mode"} & '18446744073709490175', $lName)) 0 0 0
Condition0%0/3
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') and not chmod($f->{"mode"} & '18446744073709490175', $lName)
!ll&&!rl&&r
000
MC/DC0%0/2
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') and not chmod($f->{"mode"} & '18446744073709490175', $lName)
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') not chmod($f->{"mode"} & '18446744073709490175', $lName)
Truth table0%0/3
A and not(B)
A= ($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175')B= not chmod($f->{"mode"} & '18446744073709490175', $lName)
ABresult
0X0
100
111
296 && !chmod($f->{mode} & ~S_IFMT, $lName) ) {
297 0 $fio->log(sprintf("Can't chmod(%s, 0%o)", $lName, $f->{mode}));
298 0 $ret = -1;
299 }
300 0 ▶ if ( ($f->{uid} != $a->{uid} || $f->{gid} != $a->{gid})
Branch: 1 branch
BranchTrueFalseTotal
if ($f->{"uid"} != $a->{"uid"} || $f->{"gid"} != $a->{"gid"} and not chown($f->{"uid"}, $f->{"gid"}, $lName)) 0 0 0
Condition0%0/6
$f->{"uid"} != $a->{"uid"} || $f->{"gid"} != $a->{"gid"} and not chown($f->{"uid"}, $f->{"gid"}, $lName)
!ll&&!rl&&r
000
$f->{"uid"} != $a->{"uid"} or $f->{"gid"} != $a->{"gid"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$f->{"uid"} != $a->{"uid"} || $f->{"gid"} != $a->{"gid"} and not chown($f->{"uid"}, $f->{"gid"}, $lName)
$f->{"uid"} != $a->{"uid"} $f->{"gid"} != $a->{"gid"} not chown($f->{"uid"}, $f->{"gid"}, $lName)
Truth table0%0/5
A or B and not(C)
A= $f->{"uid"} != $a->{"uid"}B= $f->{"gid"} != $a->{"gid"}C= not chown($f->{"uid"}, $f->{"gid"}, $lName)
ABCresult
00X0
1X00
0100
1X11
0111
301 && !chown($f->{uid}, $f->{gid}, $lName) ) {
302 0 $fio->log("Can't chown($f->{uid}, $f->{gid}, $lName)");
303 0 $ret = -1;
304 }
305 0 ▶ if ( ($f->{mtime} != $a->{mtime} || $f->{atime} != $a->{atime})
Branch: 1 branch
BranchTrueFalseTotal
if ($f->{"mtime"} != $a->{"mtime"} || $f->{"atime"} != $a->{"atime"} and not utime($f->{"atime"}, $f->{"mtime"}, $lName)) 0 0 0
Condition0%0/6
$f->{"mtime"} != $a->{"mtime"} || $f->{"atime"} != $a->{"atime"} and not utime($f->{"atime"}, $f->{"mtime"}, $lName)
!ll&&!rl&&r
000
$f->{"mtime"} != $a->{"mtime"} or $f->{"atime"} != $a->{"atime"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$f->{"mtime"} != $a->{"mtime"} || $f->{"atime"} != $a->{"atime"} and not utime($f->{"atime"}, $f->{"mtime"}, $lName)
$f->{"mtime"} != $a->{"mtime"} $f->{"atime"} != $a->{"atime"} not utime($f->{"atime"}, $f->{"mtime"}, $lName)
Truth table0%0/5
A or B and not(C)
A= $f->{"mtime"} != $a->{"mtime"}B= $f->{"atime"} != $a->{"atime"}C= not utime($f->{"atime"}, $f->{"mtime"}, $lName)
ABCresult
00X0
1X00
0100
1X11
0111
306 && !utime($f->{atime}, $f->{mtime}, $lName) ) {
307 0 $fio->log("Can't mtime($f->{atime}, $f->{mtime}, $lName)");
308 0 $ret = -1;
309 }
310 0 return $ret;
311 }
312  
313 sub statsGet
314 {
315 0 ▶ my($fio) = @_;
Subroutine statsGet: not called CC=1 SCAR=6.9
Pod documented
316  
317 0 return {};
318 }
319  
320 #
321 # Make a given directory. Returns non-zero on error.
322 #
323 sub makePath
324 {
325 0 ▶ my($fio, $f) = @_;
Subroutine makePath: not called CC=3 SCAR=24.8
Pod documented
326 0 my $localDir = $fio->localName($f->{name});
327  
328 0 ▶ return $fio->attribSet($f) if ( -d $localDir );
Branch: 1 branch
BranchTrueFalseTotal
if -d $localDir 0 0 0
329 0 File::Path::mkpath($localDir, 0, $f->{mode});
330 0 ▶ return $fio->attribSet($f) if ( -d $localDir );
Branch: 1 branch
BranchTrueFalseTotal
if -d $localDir 0 0 0
331 0 $fio->log("Can't create directory $localDir");
332 0 return -1;
333 }
334  
335 #
336 # Make a special file. Returns non-zero on error.
337 #
338 sub makeSpecial
339 {
340 0 ▶ my($fio, $f) = @_;
Subroutine makeSpecial: not called CC=7 SCAR=40.3
Pod documented
341 0 my $localPath = $fio->localName($f->{name});
342  
343 #
344 # TODO: check if the special file is the same, then do nothing.
345 # Should also create as a new unique name, then rename/unlink.
346 #
347 0 $fio->unlink($f->{name});
348 0 ▶ if ( ($f->{mode} & S_IFMT) == S_IFCHR ) {
Branch: 4 branches
BranchTrueFalseTotal
if (($f->{'mode'} & 61440) == 8192) { } 0 0 0
elsif (($f->{'mode'} & 61440) == 24576) { } 0 0 0
elsif (($f->{'mode'} & 61440) == 40960) { } 0 0 0
elsif (($f->{'mode'} & 61440) == 4096) { } 0 0 0
349 0 my($major, $minor);
350  
351 0 $major = $f->{rdev} >> 8;
352 0 $minor = $f->{rdev} & 0xff;
353 0 return system("mknod $localPath c $major $minor");
354 } elsif ( ($f->{mode} & S_IFMT) == S_IFBLK ) {
355 0 my($major, $minor);
356  
357 0 $major = $f->{rdev} >> 8;
358 0 $minor = $f->{rdev} & 0xff;
359 0 return system("mknod $localPath b $major $minor");
360 } elsif ( ($f->{mode} & S_IFMT) == S_IFLNK ) {
361 0 ▶ if ( !symlink($f->{link}, $localPath) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (symlink $f->{"link"}, $localPath) 0 0 0
362 # error
363 }
364 } elsif ( ($f->{mode} & S_IFMT) == S_IFIFO ) {
365 0 ▶ if ( system("mknod $localPath p") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (system "mknod $localPath p") 0 0 0
366 # error
367 }
368 }
369 0 return $fio->attribSet($f);
370 }
371  
372 #
373 # Make a hardlink. Returns non-zero on error.
374 # This actually gets called twice for each hardlink.
375 # Once as the file list is processed, and again at
376 # the end. This subroutine should decide whether it
377 # should do the hardlinks during the transer or at
378 # the end. Normally they would be done at the end
379 # since the target might not exist until them.
380 # BackupPC does them as it goes (since it is just saving the
381 # hardlink info and not actually making hardlinks).
382 #
383 sub makeHardLink
384 {
385 0 ▶ my($fio, $f, $end) = @_;
Subroutine makeHardLink: not called CC=3 SCAR=24.8
Pod undocumented
386  
387 #
388 # In this case, only do hardlinks at the end.
389 #
390 0 ▶ return if ( !$end );
Branch: 1 branch
BranchTrueFalseTotal
unless $end 0 0 0
391 0 my $localPath = $fio->localName($f->{name});
392 0 my $destLink = $fio->localName($f->{hlink});
393 0 ▶ $fio->unlink($localPath) if ( -e $localPath );
Branch: 1 branch
BranchTrueFalseTotal
if -e $localPath 0 0 0
394 0 return !link($destLink, $localPath);
395 }
396  
397  
398 sub unlink
399 {
400 0 ▶ my($fio, $path) = @_;
Subroutine unlink: not called CC=4 SCAR=30.0
Pod documented
401 0 my $localPath = $fio->localName($path);
402  
403 0 ▶ return if ( !-e $localPath && !-l $localPath );
Branch: 1 branch
BranchTrueFalseTotal
unless -e $localPath or -l $localPath 0 0 0
Condition0%0/3
-e $localPath or -l $localPath
l!l&&r!l&&!r
000
MC/DC0%0/2
-e $localPath or -l $localPath
-e $localPath -l $localPath
Truth table0%0/3
A or B
A= -e $localPathB= -l $localPath
ABresult
1X1
011
000
404 0 ▶ if ( -d _ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d _) { } 0 0 0
405 0 rmtree($localPath);
406 } else {
407 0 CORE::unlink($localPath);
408 }
409 }
410  
411 sub ignoreAttrOnFile
412 {
413 0 ▶ return undef;
Subroutine ignoreAttrOnFile: not called CC=1 SCAR=6.9
Pod documented
414 }
415  
416 #
417 # Start receive of file deltas for a particular file.
418 #
419 sub fileDeltaRxStart
420 {
421 0 ▶ my($fio, $f, $cnt, $size, $remainder) = @_;
Subroutine fileDeltaRxStart: not called CC=4 SCAR=30.0
Pod documented
422  
423 0 $fio->{rxFile} = $f; # file attributes
424 0 $fio->{rxBlkCnt} = $cnt; # how many blocks we will receive
425 0 $fio->{rxBlkSize} = $size; # block size
426 0 $fio->{rxRemainder} = $remainder; # size of the last block
427 0 $fio->{rxMatchBlk} = 0; # current start of match
428 0 $fio->{rxMatchNext} = 0; # current next block of match
429 0 $fio->{rxSize} = 0; # size of received file
430 0 ▶ if ( $fio->{rxFile}{size} != ($cnt > 0
Branch: 2 branches
BranchTrueFalseTotal
if ($fio->{"rxFile"}{"size"} != ($cnt > 0 ? ($cnt - 1) * $size + $remainder : 0)) 0 0 0
$cnt > 0 ? : 0 0 0
431 ? ($cnt - 1) * $size + $remainder
432 : 0) ) {
433 0 $fio->{rxMatchBlk} = undef; # size different, so no file match
434 $fio->log("$fio->{rxFile}{name}: size doesn't match"
435 . " ($fio->{rxFile}{size})")
436 0 ▶ if ( $fio->{logLevel} >= 5 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 5 0 0 0
437 }
438 0 delete($fio->{rxInFd});
439 0 delete($fio->{rxOutFd});
440 0 delete($fio->{rxDigest});
441 0 $fio->{rxFile}{localName} = $fio->localName($fio->{rxFile}{name});
442 }
443  
444 #
445 # Process the next file delta for the current file. Returns 0 if ok,
446 # -1 if not. Must be called with either a block number, $blk, or new data,
447 # $newData, (not both) defined.
448 #
449 sub fileDeltaRxNext
450 {
451 0 ▶ my($fio, $blk, $newData) = @_;
Subroutine fileDeltaRxNext: not called CC=27 SCAR=66.3
Pod documented
452  
453 0 ▶ if ( defined($blk) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $blk) 0 0 0
454 0 ▶ if ( defined($fio->{rxMatchBlk}) && $fio->{rxMatchNext} == $blk ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchNext"} == $blk) 0 0 0
Condition0%0/3
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchNext"} == $blk
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchNext"} == $blk
defined $fio->{"rxMatchBlk"} $fio->{"rxMatchNext"} == $blk
Truth table0%0/3
A and B
A= defined $fio->{"rxMatchBlk"}B= $fio->{"rxMatchNext"} == $blk
ABresult
0X0
100
111
455 #
456 # got the next block in order; just keep track.
457 #
458 0 $fio->{rxMatchNext}++;
459 0 return;
460 }
461 }
462 0 my $newDataLen = length($newData);
463 $fio->log("$fio->{rxFile}{name}: blk=$blk, newData=$newDataLen,"
464 . " rxMatchBlk=$fio->{rxMatchBlk}, rxMatchNext=$fio->{rxMatchNext}")
465 0 ▶ if ( $fio->{logLevel} >= 8 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 8 0 0 0
466 0 ▶ if ( !defined($fio->{rxOutFd}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fio->{"rxOutFd"}) 0 0 0
467 #
468 # maybe the file has no changes
469 #
470 0 ▶ if ( $fio->{rxMatchNext} == $fio->{rxBlkCnt}
Branch: 1 branch
BranchTrueFalseTotal
if ($fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk and not defined $newData) 0 0 0
Condition0%0/6
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk and not defined $newData
!ll&&!rl&&r
000
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk
!ll&&!rl&&r
000
MC/DC0%0/3
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk and not defined $newData
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} not defined $blk not defined $newData
Truth table0%0/4
A and not(B) and not(C)
A= $fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"}B= not defined $blkC= not defined $newData
ABCresult
0XX0
10X0
1100
1111
471 && !defined($blk) && !defined($newData) ) {
472 #$fio->log("$fio->{rxFile}{name}: file is unchanged");
473 # if ( $fio->{logLevel} >= 8 );
474 0 return;
475 }
476  
477 #
478 # need to open a temporary output file where we will build the
479 # new version.
480 #
481 0 local(*F);
482 0 my $rxTmpFile;
483 0 for ( my $i = 0 ; ; $i++ ) {
484 0 $rxTmpFile = "$fio->{rxFile}{localName}__tmp__$$.$i";
485 0 ▶ last if ( !-e $rxTmpFile );
Branch: 1 branch
BranchTrueFalseTotal
unless -e $rxTmpFile 0 0 0
486 }
487 0 ▶ if ( !open(F, ">$rxTmpFile") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, ">$rxTmpFile") 0 0 0
488 0 $fio->log("Can't open/create $rxTmpFile");
489 0 return -1;
490 }
491 $fio->log("$fio->{rxFile}{name}: opening tmp output file $rxTmpFile")
492 0 ▶ if ( $fio->{logLevel} >= 10 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 10 0 0 0
493 0 $fio->{rxOutFd} = *F;
494 0 $fio->{rxTmpFile} = $rxTmpFile;
495  
496 0 $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version});
497 0 $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed}));
498 }
499 0 ▶ if ( defined($fio->{rxMatchBlk})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}) 0 0 0
Condition0%0/3
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
defined $fio->{"rxMatchBlk"} $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
Truth table0%0/3
A and B
A= defined $fio->{"rxMatchBlk"}B= $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
ABresult
0X0
100
111
500 && $fio->{rxMatchBlk} != $fio->{rxMatchNext} ) {
501 #
502 # need to copy the sequence of blocks that matched
503 #
504 0 ▶ if ( !defined($fio->{rxInFd}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fio->{"rxInFd"}) 0 0 0
505 0 ▶ if ( open(F, "$fio->{rxFile}{localName}") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open F, "$fio->{'rxFile'}{'localName'}") { } 0 0 0
506 0 $fio->{rxInFd} = *F;
507 } else {
508 0 $fio->log("Unable to open $fio->{rxFile}{localName}");
509 0 return -1;
510 }
511 }
512 0 my $lastBlk = $fio->{rxMatchNext} - 1;
513 $fio->log("$fio->{rxFile}{name}: writing blocks $fio->{rxMatchBlk}.."
514 . "$lastBlk")
515 0 ▶ if ( $fio->{logLevel} >= 10 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 10 0 0 0
516 0 my $seekPosn = $fio->{rxMatchBlk} * $fio->{rxBlkSize};
517 0 ▶ if ( !sysseek($fio->{rxInFd}, $seekPosn, 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (sysseek $fio->{"rxInFd"}, $seekPosn, 0) 0 0 0
518 0 $fio->log("Unable to seek $fio->{rxFile}{localName} to $seekPosn");
519 0 return -1;
520 }
521 0 my $cnt = $fio->{rxMatchNext} - $fio->{rxMatchBlk};
522 0 my($thisCnt, $len, $data);
523 0 ▶ for ( my $i = 0 ; $i < $cnt ; $i += $thisCnt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $cnt) 0 0 0
524 0 $thisCnt = $cnt - $i;
525 0 ▶ $thisCnt = 512 if ( $thisCnt > 512 );
Branch: 1 branch
BranchTrueFalseTotal
if $thisCnt > 512 0 0 0
526 0 ▶ if ( $fio->{rxMatchBlk} + $i + $thisCnt == $fio->{rxBlkCnt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fio->{'rxMatchBlk'} + $i + $thisCnt == $fio->{'rxBlkCnt'}) { } 0 0 0
527 0 $len = ($thisCnt - 1) * $fio->{rxBlkSize} + $fio->{rxRemainder};
528 } else {
529 0 $len = $thisCnt * $fio->{rxBlkSize};
530 }
531 0 ▶ if ( sysread($fio->{rxInFd}, $data, $len) != $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread($fio->{"rxInFd"}, $data, $len) != $len) 0 0 0
532 0 $fio->log("Unable to read $len bytes from"
533 . " $fio->{rxFile}{localName} ($i,$thisCnt,$fio->{rxBlkCnt})");
534 0 return -1;
535 }
536 0 ▶ if ( syswrite($fio->{rxOutFd}, $data) != $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if (syswrite($fio->{"rxOutFd"}, $data) != $len) 0 0 0
537 0 $fio->log("Unable to write $len bytes to"
538 . " $fio->{rxTmpFile}");
539 }
540 0 $fio->{rxDigest}->add($data);
541 0 $fio->{rxSize} += length($data);
542 }
543 0 $fio->{rxMatchBlk} = undef;
544 }
545 0 ▶ if ( defined($blk) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $blk) 0 0 0
546 #
547 # Remember the new block number
548 #
549 0 $fio->{rxMatchBlk} = $blk;
550 0 $fio->{rxMatchNext} = $blk + 1;
551 }
552 0 ▶ if ( defined($newData) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newData) 0 0 0
553 #
554 # Write the new chunk
555 #
556 0 my $len = length($newData);
557 $fio->log("$fio->{rxFile}{name}: writing $len bytes new data")
558 0 ▶ if ( $fio->{logLevel} >= 10 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 10 0 0 0
559 0 ▶ if ( syswrite($fio->{rxOutFd}, $newData) != $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if (syswrite($fio->{"rxOutFd"}, $newData) != $len) 0 0 0
560 0 $fio->log("Unable to write $len bytes to $fio->{rxTmpFile}");
561 0 return -1;
562 }
563 0 $fio->{rxDigest}->add($newData);
564 0 $fio->{rxSize} += length($newData);
565 }
566 0 return;
567 }
568  
569 #
570 # Finish up the current receive file. Returns undef if ok, -1 if not.
571 # Returns 1 if the md4 digest doesn't match.
572 #
573 sub fileDeltaRxDone
574 {
575 0 ▶ my($fio, $md4) = @_;
Subroutine fileDeltaRxDone: not called CC=21 SCAR=61.4
Pod documented
576  
577 0 ▶ if ( !defined($fio->{rxDigest}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fio->{"rxDigest"}) 0 0 0
578 0 local(*F);
579 #
580 # File was exact match, but we still need to verify the
581 # MD4 checksum. Therefore open and read the file.
582 #
583 0 $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version});
584 0 $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed}));
585 0 ▶ if ( open(F, $fio->{rxFile}{localName}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open F, $fio->{'rxFile'}{'localName'}) { } 0 0 0
586 0 $fio->{rxInFd} = *F;
587 0 ▶ while ( sysread($fio->{rxInFd}, my $data, 4 * 65536) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (sysread($fio->{"rxInFd"}, my $data, 262144) > 0) 0 0 0
588 0 $fio->{rxDigest}->add($data);
589 0 $fio->{rxSize} += length($data);
590 }
591 } else {
592 # error
593 }
594 $fio->log("$fio->{rxFile}{name}: got exact match")
595 0 ▶ if ( $fio->{logLevel} >= 5 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 5 0 0 0
596 }
597 0 ▶ close($fio->{rxInFd}) if ( defined($fio->{rxInFd}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"rxInFd"} 0 0 0
598 0 ▶ close($fio->{rxOutFd}) if ( defined($fio->{rxOutFd}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"rxOutFd"} 0 0 0
599 0 my $newDigest = $fio->{rxDigest}->digest;
600 0 ▶ if ( $fio->{logLevel} >= 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fio->{"logLevel"} >= 3) 0 0 0
601 0 my $md4Str = unpack("H*", $md4);
602 0 my $newStr = unpack("H*", $newDigest);
603 0 $fio->log("$fio->{rxFile}{name}: got digests $md4Str vs $newStr")
604 }
605 0 ▶ if ( $md4 eq $newDigest ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($md4 eq $newDigest) { } 0 0 0
606 #
607 # Nothing to do if there is no output file
608 #
609 0 ▶ if ( !defined($fio->{rxOutFd}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fio->{"rxOutFd"}) 0 0 0
610 $fio->log("$fio->{rxFile}{name}: nothing to do")
611 0 ▶ if ( $fio->{logLevel} >= 5 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 5 0 0 0
612 0 return $fio->attribSet($fio->{rxFile});
613 }
614  
615 #
616 # First rename the original file (in case the rename below fails)
617 # to a unique temporary name.
618 #
619 0 my $oldFile;
620 0 ▶ if ( -e $fio->{rxFile}{localName} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $fio->{"rxFile"}{"localName"}) 0 0 0
621 0 for ( my $i = 0 ; ; $i++ ) {
622 0 $oldFile = "$fio->{rxFile}{localName}__old__$$.$i";
623 0 ▶ last if ( !-e $oldFile );
Branch: 1 branch
BranchTrueFalseTotal
unless -e $oldFile 0 0 0
624 }
625 $fio->log("$fio->{rxFile}{name}: unlinking/renaming")
626 0 ▶ if ( $fio->{logLevel} >= 5 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 5 0 0 0
627 0 ▶ if ( !rename($fio->{rxFile}{localName}, $oldFile) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (rename $fio->{"rxFile"}{"localName"}, $oldFile) 0 0 0
628 0 $fio->log("Can't rename $fio->{rxFile}{localName}"
629 . " to $oldFile");
630 0 CORE::unlink($fio->{rxTmpFile});
631 0 return -1;
632 }
633 }
634 0 ▶ if ( !rename($fio->{rxTmpFile}, $fio->{rxFile}{localName}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (rename $fio->{"rxTmpFile"}, $fio->{"rxFile"}{"localName"}) 0 0 0
635 #
636 # Restore old file
637 #
638 0 ▶ if ( !rename($oldFile, $fio->{rxFile}{localName}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not rename($oldFile, $fio->{'rxFile'}{'localName'})) { } 0 0 0
639 0 $fio->log("Can't retore original file $oldFile after rename"
640 . " of $fio->{rxTmpFile} failed");
641 } else {
642 0 $fio->log("Can't rename $fio->{rxTmpFile} to"
643 . " $fio->{rxFile}{localName}");
644 }
645 0 return -1;
646 }
647 0 ▶ if ( defined($oldFile) && CORE::unlink($oldFile) != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldFile and CORE::unlink($oldFile) != 1) 0 0 0
Condition0%0/3
defined $oldFile and CORE::unlink($oldFile) != 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oldFile and CORE::unlink($oldFile) != 1
defined $oldFile CORE::unlink($oldFile) != 1
Truth table0%0/3
A and B
A= defined $oldFileB= CORE::unlink($oldFile) != 1
ABresult
0X0
100
111
648 0 $fio->log("Can't unlink old file $oldFile");
649 0 return -1;
650 }
651 } else {
652 $fio->log("$fio->{rxFile}{name}: md4 doesn't match")
653 0 ▶ if ( $fio->{logLevel} >= 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 1 0 0 0
654 0 ▶ CORE::unlink($fio->{rxTmpFile}) if ( defined($fio->{rxTmpFile}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $fio->{"rxTmpFile"} 0 0 0
655 0 return 1;
656 }
657 0 delete($fio->{rxDigest});
658 0 $fio->{rxFile}{size} = $fio->{rxSize};
659 0 return $fio->attribSet($fio->{rxFile});
660 }
661  
662 sub fileListEltSend
663 {
664 0 ▶ my($fio, $name, $fList, $outputFunc) = @_;
Subroutine fileListEltSend: not called CC=7 SCAR=40.3
Pod undocumented
665 0 my @s;
666 0 my $extra = {};
667  
668 0 (my $n = $name) =~ s/^\Q$fio->{localDir}/$fio->{remoteDir}/;
669 0 ▶ if ( -l $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-l $name) { } 0 0 0
670 0 @s = lstat($name);
671 0 $extra = {
672 %$extra,
673 link => readlink($name),
674 };
675 } else {
676 0 @s = stat($name);
677 }
678 0 ▶ if ( $fio->{preserve_hard_links}
Branch: 1 branch
BranchTrueFalseTotal
if ($fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768 and $fio->{"protocol_version"} < 27 || $s[3] > 1) 0 0 0
Condition0%0/9
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768 and $fio->{"protocol_version"} < 27 || $s[3] > 1
!ll&&!rl&&r
000
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768
!ll&&!rl&&r
000
$fio->{"protocol_version"} < 27 or $s[3] > 1
l!l&&r!l&&!r
000
MC/DC0%0/4
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768 and $fio->{"protocol_version"} < 27 || $s[3] > 1
$fio->{"preserve_hard_links"} ($s[2] & 61440) == 32768 $fio->{"protocol_version"} < 27 $s[3] > 1
Truth table0%0/5
A and B and C or D
A= $fio->{"preserve_hard_links"}B= ($s[2] & 61440) == 32768C= $fio->{"protocol_version"} < 27D= $s[3] > 1
ABCDresult
0XXX0
10XX0
11000
111X1
11011
679 && ($s[2] & S_IFMT) == S_IFREG
680 && ($fio->{protocol_version} < 27 || $s[3] > 1) ) {
681 0 $extra = {
682 %$extra,
683 dev => $s[0],
684 inode => $s[1],
685 };
686 }
687 0 ▶ $fio->log("fileList send $name (remote=$n)") if ( $fio->{logLevel} >= 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $fio->{"logLevel"} >= 3 0 0 0
688 0 $fList->encode({
689 name => $n,
690 mode => $s[2],
691 uid => $s[4],
692 gid => $s[5],
693 rdev => $s[6],
694 size => $s[7],
695 mtime => $s[9],
696 %$extra,
697 });
698 0 &$outputFunc($fList->encodeData);
699 }
700  
701 sub fileListSend
702 {
703 0 ▶ my($fio, $flist, $outputFunc) = @_;
Subroutine fileListSend: not called CC=1 SCAR=6.9
Pod documented
704  
705 find({wanted => sub {
706 0 ▶ $fio->fileListEltSend($File::Find::name, $flist, $outputFunc);
Subroutine __ANON__: not called CC=1 SCAR=6.9
707 },
708 no_chdir => 1
709 0 }, $fio->{localDir});
710 }
711  
712 sub finish
713 {
714 0 ▶ my($fio, $isChild) = @_;
Subroutine finish: not called CC=1 SCAR=6.9
Pod documented
715  
716 0 return;
717 }
718  
719 #
720 # Default log handler
721 #
722 sub logHandler
723 {
724 0 ▶ my($str) = @_;
Subroutine logHandler: not called CC=1 SCAR=6.9
Pod documented
725  
726 0 print(STDERR $str, "\n");
727 }
728  
729 #
730 # Handle one or more log messages
731 #
732 sub log
733 {
734 0 ▶ my($fio, @logStr) = @_;
Subroutine log: not called CC=3 SCAR=24.8
Pod documented
735  
736 0 foreach my $str ( @logStr ) {
737 0 ▶ next if ( $str eq "" );
Branch: 1 branch
BranchTrueFalseTotal
if $str eq "" 0 0 0
738 0 $fio->{logHandler}->($str);
739 }
740 }
741  
742 1 1;
743 __END__
« blib/lib/File/RsyncP.pm ↑ Summary blib/lib/File/RsyncP/Digest.pm »