FTPTurboSync/RemoteFile.pm

filter: Statementstmt 31.2% 10 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 20.0% 13 / 65 CC 8 SCAR 33.8
CC
8
Cov
20%
set
56.0
writeToDb
6.0
deleteRemoteObjAndCheck
2.0
CRAP 29.4
« FTPTurboSync.pm ↑ Summary FTPTurboSync/TurboPutCommand.pm »
1 package Net::FTPTurboSync::RemoteFile;
2  
3 1 ▶use Net::FTPTurboSync::FileLeaf;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Net::FTPTurboSync::MixRemote;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base qw(Net::FTPTurboSync::FileLeaf Net::FTPTurboSync::MixRemote);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub deleteRemoteObjAndCheck {
Subroutine deleteRemoteObjAndCheck: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ( $self, $path, $ftp ) = @_;
10 0 return $ftp->delete ( $path ) or ! $ftp->size( $path );
11 }
12 #load info about remote file from db
13 # remote file already exists
14 0 ▶sub instantiateObject {
Subroutine instantiateObject: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my ( $class, $path, $info ) = @_ ;
16 return $class->new ( $path,
17 $info->{perms},
18 $info->{date},
19 0 $info->{size} );
20 }
21  
22 0 ▶sub writeToDb {
Subroutine writeToDb: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my ( $self, $localf ) = @_;
24 0 ▶ if ( $self->isNew ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isNew) { } 0 0 0
25 0 $self->{_new}=0;
26 0 $self->setPath ( $localf->getPath );
27 #insert db
28 0 $self->{dbh}->uploadFile ( $self->getPath,
29 $self->getPerms,
30 $self->getModDate,
31 $self->getSize );
32 }else {
33 # update db
34 0 $self->{dbh}->reuploadFile ( $self->getPath,
35 $self->getPerms,
36 $self->getModDate,
37 $self->getSize );
38 }
39 }
40 0 ▶sub set {
Subroutine set: not called CC=7 SCAR=40.3
Pod undocumented
41 0 my ( $self, $localf ) = @_;
42 0 ▶ if ( $self->isNew
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isNew or $self->getSize != $localf->getSize or $self->getModDate < $localf->getModDate) 0 0 0
Condition0%0/6
$self->isNew or $self->getSize != $localf->getSize or $self->getModDate < $localf->getModDate
l!l&&r!l&&!r
000
$self->isNew or $self->getSize != $localf->getSize
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->isNew or $self->getSize != $localf->getSize or $self->getModDate < $localf->getModDate
$self->isNew $self->getSize != $localf->getSize $self->getModDate < $localf->getModDate
Truth table0%0/4
A or B or C
A= $self->isNewB= $self->getSize != $localf->getSizeC= $self->getModDate < $localf->getModDate
ABCresult
1XX1
01X1
0011
0000
43 or $self->getSize != $localf->getSize
44 or $self->getModDate < $localf->getModDate ) {
45 0 my $p = $localf->getPath;
46 0 my $res = $self->{ftp}->put( $p, $p );
47 0 ▶ if ( !defined( $res ) or ($res ne $p) ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $res or $res ne $p) 0 0 0
Condition0%0/3
not defined $res or $res ne $p
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $res or $res ne $p
not defined $res $res ne $p
Truth table0%0/3
not(A) or B
A= not defined $resB= $res ne $p
ABresult
1X1
011
000
48 0 NetWorkEx->throw ( "Could not put '" . $localf->getPath . "' file" );
49 }
50 0 $self->setSize ( $localf->getSize );
51 0 $self->setModDate ( $localf->getModDate() );
52 }
53
54 0 ▶ if ( $self->getPerms != $localf->getPerms ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getPerms != $localf->getPerms) 0 0 0
55 0 $self->{ftp}->setPerms ( $localf->getPath, $localf->getPerms );
56 0 $self->setPerms ( $localf->getPerms );
57 }
58 0 $self->writeToDb ( $localf );
59 }
60  
61 1 1;
« FTPTurboSync.pm ↑ Summary FTPTurboSync/TurboPutCommand.pm »