line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FTPTurboSync::RemoteFile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Net::FTPTurboSync::FileLeaf; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
4
|
use Net::FTPTurboSync::MixRemote; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base qw(Net::FTPTurboSync::FileLeaf Net::FTPTurboSync::MixRemote); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
406
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub deleteRemoteObjAndCheck { |
9
|
0
|
|
|
0
|
0
|
|
my ( $self, $path, $ftp ) = @_; |
10
|
0
|
0
|
|
|
|
|
return $ftp->delete ( $path ) or ! $ftp->size( $path ); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
#load info about remote file from db |
13
|
|
|
|
|
|
|
# remote file already exists |
14
|
|
|
|
|
|
|
sub instantiateObject { |
15
|
0
|
|
|
0
|
0
|
|
my ( $class, $path, $info ) = @_ ; |
16
|
0
|
|
|
|
|
|
return $class->new ( $path, |
17
|
|
|
|
|
|
|
$info->{perms}, |
18
|
|
|
|
|
|
|
$info->{date}, |
19
|
|
|
|
|
|
|
$info->{size} ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub writeToDb { |
23
|
0
|
|
|
0
|
0
|
|
my ( $self, $localf ) = @_; |
24
|
0
|
0
|
|
|
|
|
if ( $self->isNew ){ |
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
|
|
|
|
|
|
|
sub set { |
41
|
0
|
|
|
0
|
0
|
|
my ( $self, $localf ) = @_; |
42
|
0
|
0
|
0
|
|
|
|
if ( $self->isNew |
|
|
|
0
|
|
|
|
|
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
|
0
|
0
|
|
|
|
if ( !defined( $res ) or ($res ne $p) ){ |
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
|
0
|
|
|
|
|
if ( $self->getPerms != $localf->getPerms ){ |
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; |