| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Sky::Manager; |
|
2
|
|
|
|
|
|
|
$App::Sky::Manager::VERSION = '0.4.1'; |
|
3
|
1
|
|
|
1
|
|
70736
|
use strict; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Carp (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
424
|
use Moo; |
|
|
1
|
|
|
|
|
9251
|
|
|
|
1
|
|
|
|
|
4
|
|
|
10
|
1
|
|
|
1
|
|
1516
|
use MooX 'late'; |
|
|
1
|
|
|
|
|
8297
|
|
|
|
1
|
|
|
|
|
6
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
21580
|
use List::Util qw(first); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
102
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
539
|
use URI; |
|
|
1
|
|
|
|
|
3831
|
|
|
|
1
|
|
|
|
|
27
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use File::Basename qw(basename); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
69
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
360
|
use App::Sky::Module; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# For defined-or - "//". |
|
20
|
1
|
|
|
1
|
|
15
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has config => ( isa => 'HashRef', is => 'ro', ); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _calc_site_conf |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
15
|
|
|
15
|
|
17
|
my ( $self, $args ) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
15
|
|
|
|
|
27
|
my $config = $self->config; |
|
30
|
|
|
|
|
|
|
|
|
31
|
15
|
|
|
|
|
32
|
return $config->{sites}->{ $config->{default_site} }; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _calc_sect_name |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
6
|
|
|
6
|
|
12
|
my ( $self, $args, $sections ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
8
|
my $bn = $args->{basename}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
8
|
my $sect_name = $args->{section}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
6
|
100
|
|
|
|
11
|
if ( !defined($sect_name) ) |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
5
|
100
|
|
|
|
9
|
if ( $args->{is_dir} ) |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
2
|
|
|
|
|
4
|
$sect_name = $self->_calc_site_conf($args)->{dirs_section}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
else |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
|
|
|
|
|
|
$sect_name = ( |
|
51
|
|
|
|
|
|
|
first |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
5
|
|
|
5
|
|
9
|
my $re = $sections->{$_}->{basename_re}; |
|
54
|
5
|
|
|
|
|
111
|
$bn =~ /$re/; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
3
|
|
|
|
|
17
|
( keys(%$sections) ) |
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
6
|
50
|
|
|
|
21
|
if ( !defined($sect_name) ) |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
0
|
|
|
|
|
0
|
Carp::confess("Unknown section for basename '$bn'"); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
6
|
50
|
|
|
|
12
|
if ( !exists( $sections->{$sect_name} ) ) |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
|
|
0
|
Carp::confess("Section '$sect_name' does not exist."); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
10
|
return $sect_name; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _calc_target_dir |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
7
|
|
|
7
|
|
12
|
my ( $self, $args ) = @_; |
|
77
|
|
|
|
|
|
|
|
|
78
|
7
|
100
|
|
|
|
14
|
if ( defined( $args->{target_dir} ) ) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
1
|
|
|
|
|
5
|
return $args->{target_dir}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else |
|
83
|
|
|
|
|
|
|
{ |
|
84
|
6
|
|
|
|
|
17
|
my $sections = $self->_calc_site_conf($args)->{sections}; |
|
85
|
|
|
|
|
|
|
|
|
86
|
6
|
|
|
|
|
10
|
my $sect_name = $self->_calc_sect_name( $args, $sections ); |
|
87
|
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
28
|
return $sections->{$sect_name}->{target_dir}; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _perform_upload_generic |
|
93
|
|
|
|
|
|
|
{ |
|
94
|
7
|
|
|
7
|
|
12
|
my ( $self, $is_dir, $args ) = @_; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $filenames = $args->{filenames} |
|
97
|
7
|
50
|
|
|
|
18
|
or Carp::confess("Missing argument 'filenames'"); |
|
98
|
|
|
|
|
|
|
|
|
99
|
7
|
50
|
|
|
|
14
|
if ( @$filenames != 1 ) |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
0
|
|
|
|
|
0
|
Carp::confess("More than one file passed to 'filenames'"); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
13
|
my $site_conf = $self->_calc_site_conf($args); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $backend = App::Sky::Module->new( |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
|
|
|
|
|
|
base_upload_cmd => $site_conf->{base_upload_cmd}, |
|
109
|
|
|
|
|
|
|
dest_upload_prefix => $site_conf->{dest_upload_prefix}, |
|
110
|
|
|
|
|
|
|
dest_upload_url_prefix => $site_conf->{dest_upload_url_prefix}, |
|
111
|
|
|
|
|
|
|
} |
|
112
|
7
|
|
|
|
|
138
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
7
|
|
|
|
|
2590
|
my $fn = $filenames->[0]; |
|
115
|
7
|
|
|
|
|
218
|
my $bn = basename($fn); |
|
116
|
|
|
|
|
|
|
|
|
117
|
7
|
100
|
|
|
|
23
|
my @dir = ( $is_dir ? ( is_dir => 1 ) : () ); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
return $backend->get_upload_results( |
|
120
|
|
|
|
|
|
|
{ |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
filenames => ( |
|
123
|
|
|
|
|
|
|
$is_dir |
|
124
|
7
|
100
|
|
|
|
28
|
? [ map { my $s = $_; $s =~ s#/+\z##ms; $s } @$filenames ] |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
9
|
|
|
125
|
|
|
|
|
|
|
: $filenames, |
|
126
|
|
|
|
|
|
|
), |
|
127
|
|
|
|
|
|
|
target_dir => $self->_calc_target_dir( |
|
128
|
|
|
|
|
|
|
{ |
|
129
|
|
|
|
|
|
|
%$args, |
|
130
|
|
|
|
|
|
|
basename => $bn, |
|
131
|
|
|
|
|
|
|
@dir, |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
), |
|
134
|
|
|
|
|
|
|
@dir, |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub get_upload_results |
|
142
|
|
|
|
|
|
|
{ |
|
143
|
5
|
|
|
5
|
1
|
21338
|
my ( $self, $args ) = @_; |
|
144
|
|
|
|
|
|
|
|
|
145
|
5
|
|
|
|
|
11
|
return $self->_perform_upload_generic( 0, $args ); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get_recursive_upload_results |
|
150
|
|
|
|
|
|
|
{ |
|
151
|
2
|
|
|
2
|
1
|
4600
|
my ( $self, $args ) = @_; |
|
152
|
|
|
|
|
|
|
|
|
153
|
2
|
|
|
|
|
4
|
return $self->_perform_upload_generic( 1, $args ); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |