line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sky::Module; |
2
|
|
|
|
|
|
|
$App::Sky::Module::VERSION = '0.4.1'; |
3
|
2
|
|
|
2
|
|
82074
|
use strict; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
52
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use Carp (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
34
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
455
|
use Moo; |
|
2
|
|
|
|
|
9811
|
|
|
2
|
|
|
|
|
11
|
|
10
|
2
|
|
|
2
|
|
1922
|
use MooX 'late'; |
|
2
|
|
|
|
|
8944
|
|
|
2
|
|
|
|
|
12
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
23127
|
use URI; |
|
2
|
|
|
|
|
4104
|
|
|
2
|
|
|
|
|
59
|
|
13
|
2
|
|
|
2
|
|
11
|
use File::Basename qw(basename); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
126
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
987
|
use List::MoreUtils qw( uniq ); |
|
2
|
|
|
|
|
22357
|
|
|
2
|
|
|
|
|
11
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
2489
|
use App::Sky::Results; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
81
|
|
18
|
2
|
|
|
2
|
|
729
|
use App::Sky::Exception; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
554
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has base_upload_cmd => ( isa => 'ArrayRef[Str]', is => 'ro', ); |
21
|
|
|
|
|
|
|
has dest_upload_prefix => ( isa => 'Str', is => 'ro', ); |
22
|
|
|
|
|
|
|
has dest_upload_url_prefix => ( isa => 'Str', is => 'ro', ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_upload_results |
26
|
|
|
|
|
|
|
{ |
27
|
11
|
|
|
11
|
1
|
20038
|
my ( $self, $args ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
11
|
|
100
|
|
|
48
|
my $is_dir = ( $args->{is_dir} // 0 ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $filenames = $args->{filenames} |
32
|
11
|
50
|
|
|
|
33
|
or Carp::confess("Missing argument 'filenames'"); |
33
|
|
|
|
|
|
|
|
34
|
11
|
50
|
|
|
|
27
|
if ( @$filenames != 1 ) |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
0
|
Carp::confess("More than one file passed to 'filenames'"); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $target_dir = $args->{target_dir} |
40
|
11
|
50
|
|
|
|
22
|
or Carp::confess("Missing argument 'target_dir'"); |
41
|
|
|
|
|
|
|
|
42
|
11
|
|
|
|
|
39
|
my $invalid_chars_re = qr/[:]/; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @invalid_chars = |
45
|
11
|
|
|
|
|
21
|
( map { split( //, $_ ) } map { /($invalid_chars_re)/g } @$filenames ); |
|
1
|
|
|
|
|
5
|
|
|
11
|
|
|
|
|
83
|
|
46
|
|
|
|
|
|
|
|
47
|
11
|
100
|
|
|
|
28
|
if (@invalid_chars) |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
App::Sky::Exception::Upload::Filename::InvalidChars->throw( |
50
|
1
|
|
|
|
|
26
|
invalid_chars => [ sort { $a cmp $b } uniq(@invalid_chars) ], ); |
|
0
|
|
|
|
|
0
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return App::Sky::Results->new( |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
upload_cmd => [ |
56
|
10
|
100
|
|
|
|
14
|
@{ $self->base_upload_cmd() }, |
|
10
|
|
|
|
|
366
|
|
57
|
|
|
|
|
|
|
@$filenames, |
58
|
|
|
|
|
|
|
( $self->dest_upload_prefix() . $target_dir ), |
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
urls => [ |
61
|
|
|
|
|
|
|
URI->new( |
62
|
|
|
|
|
|
|
$self->dest_upload_url_prefix() |
63
|
|
|
|
|
|
|
. $target_dir |
64
|
|
|
|
|
|
|
. basename( $filenames->[0] ) |
65
|
|
|
|
|
|
|
. ( $is_dir ? '/' : '' ) |
66
|
|
|
|
|
|
|
), |
67
|
|
|
|
|
|
|
], |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |