line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::FTP::Client::Transfer; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
13896
|
use strict; |
|
24
|
|
|
|
|
63
|
|
|
24
|
|
|
|
|
766
|
|
4
|
24
|
|
|
24
|
|
160
|
use warnings; |
|
24
|
|
|
|
|
58
|
|
|
24
|
|
|
|
|
920
|
|
5
|
24
|
|
|
24
|
|
423
|
use 5.010; |
|
24
|
|
|
|
|
88
|
|
6
|
24
|
|
|
24
|
|
158
|
use Moo; |
|
24
|
|
|
|
|
60
|
|
|
24
|
|
|
|
|
138
|
|
7
|
24
|
|
|
24
|
|
8347
|
use AnyEvent; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
676
|
|
8
|
24
|
|
|
24
|
|
167
|
use AnyEvent::Handle; |
|
24
|
|
|
|
|
70
|
|
|
24
|
|
|
|
|
765
|
|
9
|
24
|
|
|
24
|
|
174
|
use Carp qw( confess ); |
|
24
|
|
|
|
|
67
|
|
|
24
|
|
|
|
|
12226
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Transfer class for asynchronous ftp client |
12
|
|
|
|
|
|
|
our $VERSION = '0.18'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# TODO: implement ABOR |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'AnyEvent::FTP::Role::Event'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->define_events(qw( open close eof )); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has cv => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
lazy => 1, |
26
|
|
|
|
|
|
|
default => sub { AnyEvent->condvar }, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has client => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has remote_name => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
lazy => 1, |
37
|
|
|
|
|
|
|
default => sub { shift->command->[1] }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has local => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has command => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
required => 1, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has restart => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
default => sub { 0 }, |
53
|
|
|
|
|
|
|
coerce => sub { $_[0] // 0 }, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
24
|
|
|
24
|
1
|
799
|
sub cb { shift->{cv}->cb(@_) } |
58
|
0
|
|
|
0
|
1
|
0
|
sub ready { shift->{cv}->ready } |
59
|
46
|
|
|
46
|
1
|
4284
|
sub recv { shift->{cv}->recv } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub handle |
62
|
|
|
|
|
|
|
{ |
63
|
70
|
|
|
70
|
0
|
207
|
my($self, $fh) = @_; |
64
|
|
|
|
|
|
|
|
65
|
70
|
|
|
|
|
115
|
my $handle; |
66
|
|
|
|
|
|
|
$handle = AnyEvent::Handle->new( |
67
|
|
|
|
|
|
|
fh => $fh, |
68
|
|
|
|
|
|
|
on_error => sub { |
69
|
21
|
|
|
21
|
|
781
|
my($hdl, $fatal, $msg) = @_; |
70
|
21
|
|
|
|
|
103
|
$self->emit('eof'); |
71
|
21
|
|
|
|
|
93
|
$_[0]->destroy; |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
on_eof => sub { |
74
|
24
|
|
|
24
|
|
2147
|
$self->emit('eof'); |
75
|
24
|
|
|
|
|
322
|
$handle->destroy; |
76
|
|
|
|
|
|
|
}, |
77
|
|
|
|
|
|
|
# this avoids deep recursion exception error (usually |
78
|
|
|
|
|
|
|
# a warning) in example fput.pl when the buffer is |
79
|
|
|
|
|
|
|
# small (1024 on my debian VM) |
80
|
70
|
|
|
|
|
942
|
autocork => 1, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
70
|
|
|
|
|
7751
|
$self->emit(open => $handle); |
84
|
|
|
|
|
|
|
|
85
|
70
|
|
|
|
|
248
|
$handle; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |