| 1 | package Amazon::S3::Bucket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use Amazon::S3::Constants qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use Amazon::S3::Util qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Digest::MD5 qw(md5 md5_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use Digest::MD5::File qw(file_md5 file_md5_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | ▶ | use File::stat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | ▶ | use IO::Scalar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | use List::Util qw(none pairs any); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | ▶ | use XML::Simple; ## no critic (DiscouragedModules) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | ▶ | use parent qw(Exporter Class::Accessor::Fast); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | our $VERSION = '2.1.4'; ## no critic (RequireInterpolation) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | __PACKAGE__->mk_accessors( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | account | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | bucket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | buffer_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | creation_date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | verify_region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=34.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 13 | my $options = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | ▶ | $options->{buffer_size} ||= $DEFAULT_BUFFER_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options->{"buffer_size"} ||= $Amazon::S3::Bucket::DEFAULT_BUFFER_SIZE
MC/DC0%0/2
$options->{"buffer_size"} ||= $Amazon::S3::Bucket::DEFAULT_BUFFER_SIZE
$options->{"buffer_size"}
$Amazon::S3::Bucket::DEFAULT_BUFFER_SIZE
Truth table33%1/3
A ||= B
A= $options->{"buffer_size"}B= $Amazon::S3::Bucket::DEFAULT_BUFFER_SIZE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | my $self = $class->SUPER::new($options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 13 | ▶ | croak 'no bucket' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | if !$self->bucket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 13 | ▶ | croak 'no account' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | if !$self->account; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 13 | ▶ | if ( !$self->logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 13 | $self->logger( $self->account->get_logger ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # now each bucket maintains its own region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 13 | ▶ | if ( !$self->region && $self->verify_region ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not $self->region and $self->verify_region
MC/DC0%0/2
not $self->region and $self->verify_region
not $self->region
$self->verify_region
Truth table33%1/3
not(A) and B
A= not $self->regionB= $self->verify_region
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $region; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( !$self->account->err ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $region = $self->get_location_constraint() // 'us-east-1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_location_constraint // "us-east-1"
MC/DC0%0/1
$self->get_location_constraint // "us-east-1"
$self->get_location_constraint
Truth table0%0/2
A
A= $self->get_location_constraint
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $self->logger->debug( sprintf "bucket: %s region: %s\n", $self->bucket, ( $region // $EMPTY ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$region // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$region // $Amazon::S3::Bucket::EMPTY
$region
$Amazon::S3::Bucket::EMPTY
Truth table0%0/3
A // B
A= $regionB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->region($region); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | elsif ( !$self->region ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->region( $self->account->region ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 13 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 10 | ▶ | sub _uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uri: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 10 | my ( $self, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 10 | ▶ | if ($key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 10 | $key =~ s/^\///xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 10 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 10 | my $uri = $self->bucket . $SLASH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 10 | ▶ | if ($key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 10 | $uri .= urlencode($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | ▶ | if ( $account->dns_bucket_names ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 10 | $uri =~ s/^\///xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub _add_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_key: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | my ( $data, $headers, $key ) = @{ $args[0] }{qw{data headers key}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | my $args = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | path => $self->_uri($key), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | return $account->send_request_expect_nothing_probed($args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | if ref $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | return $account->send_request_expect_nothing($args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | sub add_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_key: called CC=20 SCAR=40.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | my ( $key, $value, $conf, $source ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | if ( @args == 1 && ref $args[0] && reftype( $args[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@args == 1 and ref $args[0] and builtin::reftype($args[0]) eq "HASH"
@args == 1 and ref $args[0]
MC/DC0%0/3
@args == 1 and ref $args[0] and builtin::reftype($args[0]) eq "HASH"
@args == 1
ref $args[0]
builtin::reftype($args[0]) eq "HASH"
Truth table25%1/4
A and B and C
A= @args == 1B= ref $args[0]C= builtin::reftype($args[0]) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $parameters = { %{ $args[0] } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $key = delete $parameters->{key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $source = $self->_stage_upload_source($parameters); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( exists $source->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $value = $source->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $value = \$source->{filename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | delete @{$parameters}{qw(data filename fh callback)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $conf = $parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ( $key, $value, $conf ) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | croak 'must specify key' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key and length $key
MC/DC0%0/2
$key and length $key
$key
length $key
Truth table33%1/3
A and B
A= $keyB= length $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | if !$key || !length $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | $conf //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf //= {}
MC/DC0%0/1
$conf //= {}
$conf
Truth table50%1/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | my $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $headers = delete $conf->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | $headers //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$headers //= {}
MC/DC0%0/1
$headers //= {}
$headers
Truth table50%1/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if ( $conf->{acl_short} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $account->_validate_acl_short( $conf->{acl_short} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $conf->{'x-amz-acl'} = $conf->{acl_short}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | delete $conf->{acl_short}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | $headers = { %{$conf}, %{$headers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | set_md5_header( data => $value, headers => $headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my $algorithm = lc $account->checksum_algorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my $checksum_types = $account->checksum_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | if ( exists $checksum_types->{$algorithm} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | my %digest_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | if ( ref $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | $digest_parameters{filename} = ${$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | $digest_parameters{data} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | my $digest = $checksum_types->{$algorithm}->(%digest_parameters); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | $headers->{ 'x-amz-checksum-' . $algorithm } = encode_base64( $digest, $EMPTY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | if ( ref $value ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $value = _content_sub( ${$value}, $self->buffer_size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | $headers->{'x-amz-content-sha256'} = 'UNSIGNED-PAYLOAD'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | my $request_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | eval { $retval = $self->_add_key( { headers => $headers, data => $value, key => $key, }, ); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | $request_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | if ($request_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $rsp = $account->last_response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $rsp && $rsp->code eq $HTTP_MOVED_PERMANENTLY ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rsp and $rsp->code eq $Amazon::S3::Bucket::HTTP_MOVED_PERMANENTLY
MC/DC0%0/2
$rsp and $rsp->code eq $Amazon::S3::Bucket::HTTP_MOVED_PERMANENTLY
$rsp
$rsp->code eq $Amazon::S3::Bucket::HTTP_MOVED_PERMANENTLY
Truth table0%0/3
A and B
A= $rspB= $rsp->code eq $Amazon::S3::Bucket::HTTP_MOVED_PERMANENTLY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->region( $rsp->headers->{'x-amz-bucket-region'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $retval = $self->_add_key( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | data => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | my $error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | if ( $source && $source->{temporary} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$source and $source->{"temporary"}
MC/DC0%0/2
$source and $source->{"temporary"}
$source
$source->{"temporary"}
Truth table33%1/3
A and B
A= $sourceB= $source->{"temporary"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $filename = $source->{filename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( !unlink $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | warn "Could not remove temporary upload file $filename: $OS_ERROR\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | die $error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | if $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub add_key_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_key_filename: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my ( $self, $key, $filename, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $conf //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf //= {}
MC/DC0%0/1
$conf //= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | return $self->add_key( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | { %{$conf}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | filename => $filename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub _stage_upload_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stage_upload_source: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my ( $self, $parameters ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my @sources; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | foreach my $name (qw(data filename fh callback)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( $name eq 'data' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | push @sources, $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if exists $parameters->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | push @sources, $name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if defined $parameters->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | croak 'one of data, filename, fh or callback must be specified' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if !@sources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | croak 'only one of data, filename, fh or callback may be specified' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | if @sources > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $source_type = $sources[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ( $source_type eq 'data' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return { data => $parameters->{data}, }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ( $source_type eq 'filename' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | return { filename => $parameters->{filename}, }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ( $source_type eq 'fh' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $fh = $parameters->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $callback = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $read = $fh->read( $buffer, $self->buffer_size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | croak "Error while reading upload content: $OS_ERROR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | if !defined $read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if !$read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return \$buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $callback = $parameters->{callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | croak 'callback must be a reference to a subroutine' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $callback or builtin::reftype($callback) ne "CODE"
MC/DC0%0/2
not ref $callback or builtin::reftype($callback) ne "CODE"
not ref $callback
builtin::reftype($callback) ne "CODE"
Truth table0%0/3
not(A) or B
A= not ref $callbackB= builtin::reftype($callback) ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | if !ref $callback || reftype($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my ( $tmp_fh, $filename ) = tempfile( UNLINK => $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $tmp_fh->binmode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | while ($TRUE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $buffer = $callback->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if !defined $buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | croak 'upload callback must return a scalar reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $buffer or builtin::reftype($buffer) ne "SCALAR"
MC/DC0%0/2
not ref $buffer or builtin::reftype($buffer) ne "SCALAR"
not ref $buffer
builtin::reftype($buffer) ne "SCALAR"
Truth table0%0/3
not(A) or B
A= not ref $bufferB= builtin::reftype($buffer) ne "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | if !ref $buffer || reftype($buffer) ne 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | print {$tmp_fh} ${$buffer} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | or croak "Could not write temporary upload file: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | $tmp_fh->close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | or croak "Could not close temporary upload file: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | eval { $tmp_fh->close; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( -e $filename && !unlink $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $filename and not unlink($filename)
MC/DC0%0/2
-e $filename and not unlink($filename)
-e $filename
not unlink($filename)
Truth table0%0/3
A and not(B)
A= -e $filenameB= not unlink($filename)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | warn "Could not remove temporary upload file $filename: $OS_ERROR\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | filename => $filename, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | temporary => $TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub upload_multipart_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload_multipart_object: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $logger = $self->logger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $parameters = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | croak 'no key!' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | if !$parameters->{key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | croak 'either data, callback or fh must be set!' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if !$parameters->{data} && !$parameters->{callback} && !$parameters->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$parameters->{"data"} or $parameters->{"callback"} or $parameters->{"fh"}
$parameters->{"data"} or $parameters->{"callback"}
MC/DC0%0/3
$parameters->{"data"} or $parameters->{"callback"} or $parameters->{"fh"}
$parameters->{"data"}
$parameters->{"callback"}
$parameters->{"fh"}
Truth table0%0/4
A or B or C
A= $parameters->{"data"}B= $parameters->{"callback"}C= $parameters->{"fh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | croak 'callback must be a reference to a subroutine!' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | if $parameters->{callback} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | && reftype( $parameters->{callback} ) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parameters->{"callback"} and builtin::reftype($parameters->{"callback"}) ne "CODE"
MC/DC0%0/2
$parameters->{"callback"} and builtin::reftype($parameters->{"callback"}) ne "CODE"
$parameters->{"callback"}
builtin::reftype($parameters->{"callback"}) ne "CODE"
Truth table0%0/3
A and B
A= $parameters->{"callback"}B= builtin::reftype($parameters->{"callback"}) ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $parameters->{abort_on_error} //= $TRUE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parameters->{"abort_on_error"} //= $Amazon::S3::Bucket::TRUE
MC/DC0%0/2
$parameters->{"abort_on_error"} //= $Amazon::S3::Bucket::TRUE
$parameters->{"abort_on_error"}
$Amazon::S3::Bucket::TRUE
Truth table0%0/3
A //= B
A= $parameters->{"abort_on_error"}B= $Amazon::S3::Bucket::TRUE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | $parameters->{chunk_size} //= $MIN_MULTIPART_UPLOAD_CHUNK_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$parameters->{"chunk_size"} //= $Amazon::S3::Bucket::MIN_MULTIPART_UPLOAD_CHUNK_SIZE
MC/DC0%0/2
$parameters->{"chunk_size"} //= $Amazon::S3::Bucket::MIN_MULTIPART_UPLOAD_CHUNK_SIZE
$parameters->{"chunk_size"}
$Amazon::S3::Bucket::MIN_MULTIPART_UPLOAD_CHUNK_SIZE
Truth table0%0/3
A //= B
A= $parameters->{"chunk_size"}B= $Amazon::S3::Bucket::MIN_MULTIPART_UPLOAD_CHUNK_SIZE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | if ( !$parameters->{callback} && !$parameters->{fh} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parameters->{"callback"} or $parameters->{"fh"}
MC/DC0%0/2
$parameters->{"callback"} or $parameters->{"fh"}
$parameters->{"callback"}
$parameters->{"fh"}
Truth table0%0/3
A or B
A= $parameters->{"callback"}B= $parameters->{"fh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | #...but really nobody should be passing a >5MB scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | my $data = ref $parameters->{data} ? $parameters->{data} : \$parameters->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $parameters->{fh} = IO::Scalar->new($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # ...having a file handle implies, we use this callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( $parameters->{fh} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $fh = $parameters->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $fh->seek( 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $length = $fh->tell; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $fh->seek( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $logger->trace( sub { return sprintf 'length of object: %s', $length; } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | croak 'length of the object must be >= ' . $MIN_MULTIPART_UPLOAD_CHUNK_SIZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | if $length < $MIN_MULTIPART_UPLOAD_CHUNK_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | my $chunk_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | = ( $parameters->{chunk_size} && $parameters->{chunk_size} ) > $MIN_MULTIPART_UPLOAD_CHUNK_SIZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ? $parameters->{chunk_size} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | : $MIN_MULTIPART_UPLOAD_CHUNK_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parameters->{'chunk_size'} && $parameters->{'chunk_size'}
MC/DC0%0/2
$parameters->{'chunk_size'} && $parameters->{'chunk_size'}
$parameters->{'chunk_size'}
$parameters->{'chunk_size'}
Truth table0%0/3
A && B
A= $parameters->{'chunk_size'}B= $parameters->{'chunk_size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | $parameters->{callback} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if !$length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $bytes_read = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | my $n = $length >= $chunk_size ? $chunk_size : $length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $logger->trace( sprintf 'reading %d bytes', $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $bytes = $fh->read( $buffer, $n, $bytes_read ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $logger->trace( sprintf 'read %d bytes', $bytes ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $bytes_read += $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $length -= $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $logger->trace( sprintf '%s bytes left to read', $length ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return ( \$buffer, $bytes ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | my $headers = { %{ $parameters->{headers} || {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$parameters->{'headers'} || {}
MC/DC0%0/1
$parameters->{'headers'} || {}
$parameters->{'headers'}
Truth table0%0/2
A
A= $parameters->{'headers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | $headers->{'x-amz-checksum-algorithm'} //= uc $self->account->checksum_algorithm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$headers->{"x-amz-checksum-algorithm"} //= uc $self->account->checksum_algorithm
MC/DC0%0/1
$headers->{"x-amz-checksum-algorithm"} //= uc $self->account->checksum_algorithm
$headers->{"x-amz-checksum-algorithm"}
Truth table0%0/2
A
A= $headers->{"x-amz-checksum-algorithm"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | my ( $id, $algorithm ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | = $self->initiate_multipart_upload( $parameters->{key}, $headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $logger->trace( sprintf 'multipart id: %s', $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $part = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my %parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | my %return_parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my $key = $parameters->{key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $retval = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my ( $buffer, $length ) = $parameters->{callback}->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | last if !$buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my ( $etag, $checksum ) = $self->upload_part_of_multipart_upload( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | { id => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | data => $buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | part => $part, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | algorithm => $algorithm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $part_number = $part++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $parts{$part_number} = { etag => $etag, checksum => $checksum }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $return_parts{$part_number} = $etag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $self->complete_multipart_upload( $parameters->{key}, $id, \%parts, $algorithm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $err = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | warn $err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if ( $err && $parameters->{abort_on_error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$err and $parameters->{"abort_on_error"}
MC/DC0%0/2
$err and $parameters->{"abort_on_error"}
$err
$parameters->{"abort_on_error"}
Truth table0%0/3
A and B
A= $errB= $parameters->{"abort_on_error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->abort_multipart_upload( $key, $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | %parts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | %return_parts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | return \%return_parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # Initiates a multipart upload operation. This is necessary for uploading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # files > 5Gb to Amazon S3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # returns: upload ID assigned by Amazon (used to identify this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # particular upload in other operations) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 2 | ▶ | sub initiate_multipart_upload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initiate_multipart_upload: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | my ( $self, $key, $headers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | ▶ | croak 'Object key is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | my $checksum_types = $acct->checksum_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | $headers = { %{ $headers // {} } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$headers // {}
MC/DC0%0/1
$headers // {}
$headers
Truth table50%1/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | my $algorithm = $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | if ( exists $headers->{'x-amz-checksum-algorithm'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | $algorithm = lc $headers->{'x-amz-checksum-algorithm'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | ▶ | if ( none { $algorithm eq $_ } qw(crc64nvme crc32 crc32c) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | croak sprintf 'Checksum algorithm %s is not available for multipart upload', uc $algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 1 | ▶ | if !exists $checksum_types->{$algorithm}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | ▶ | if ( any { $algorithm eq $_ } qw(crc64nvme crc32 crc32c) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | $headers->{'x-amz-checksum-type'} = 'FULL_OBJECT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | method => 'POST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | path => $self->_uri($key) . '?uploads=', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 2 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 2 | my $r = $acct->_xpc_of_content( $response->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | ▶ | return wantarray ? ( $r->{UploadId}, lc $algorithm ) : $r->{UploadId}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Upload a part of a file as part of a multipart upload operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # Each part must be at least 5mb (except for the last piece). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # This returns the Amazon-generated eTag for the uploaded file segment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # It is necessary to keep track of the eTag for each part number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # The complete operation will want a sequential list of all the part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # numbers along with their eTags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 2 | ▶ | sub upload_part_of_multipart_upload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload_part_of_multipart_upload: called CC=13 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | my ( $key, $upload_id, $part_number, $data, $length, $algorithm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | ▶ | if ( @args == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | ▶ | if ( reftype( $args[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ( $key, $upload_id, $part_number, $data, $length, $algorithm ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 2 | = @{ $args[0] }{qw{ key id part data length algorithm}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | elsif ( reftype( $args[0] ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ( $key, $upload_id, $part_number, $data, $length, $algorithm ) = @{ $args[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ( $key, $upload_id, $part_number, $data, $length, $algorithm ) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # argh...wish we didn't have to do this! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | ▶ | if ( ref $data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $data = ${$data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 2 | ▶ | $length = $length || length $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$length || length $data
MC/DC0%0/2
$length || length $data
$length
length $data
Truth table33%1/3
A || B
A= $lengthB= length $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 2 | ▶ | croak 'Object key is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 2 | ▶ | croak 'Upload id is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | if !$upload_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 2 | ▶ | croak 'Part Number is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | if !$part_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | my $headers = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 2 | set_md5_header( data => $data, headers => $headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 2 | ▶ | $algorithm = lc( $algorithm // $EMPTY ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$algorithm // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$algorithm // $Amazon::S3::Bucket::EMPTY
$algorithm
$Amazon::S3::Bucket::EMPTY
Truth table33%1/3
A // B
A= $algorithmB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 2 | my $checksum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 2 | my $checksum_types = $self->account->checksum_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | ▶ | if ( exists $checksum_types->{$algorithm} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | my $digest = $checksum_types->{$algorithm}->( data => $data, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | $checksum = encode_base64( $digest, $EMPTY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 2 | $headers->{ 'x-amz-checksum-' . $algorithm } = $checksum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | my $path = create_api_uri( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | path => $self->_uri($key), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | partNumber => ${part_number}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | uploadId => ${upload_id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | my $params = $QUESTION_MARK | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | . create_query_string( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | partNumber => ${part_number}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | uploadId => ${upload_id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | $self->logger->debug( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return Dumper( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | [ part => $part_number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | length => length $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | path => $self->_uri($key) . $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | #path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # We'll need to save the etag for later when completing the transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 2 | my $etag = $response->header('ETag'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | ▶ | if ($etag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | $etag =~ s/^"//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | $etag =~ s/"$//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | return wantarray ? ( $etag, $checksum ) : $etag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # Inform Amazon that the multipart upload has been completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # You must supply a hash of part Numbers => eTags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # For amazon to use to put the file together on their servers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | sub complete_multipart_upload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_multipart_upload: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my ( $self, $key, $upload_id, $parts_hr, $algorithm ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $self->logger->debug( Dumper( [ $key, $upload_id, $parts_hr ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | croak 'Object key is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | croak 'Upload id is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | if !$upload_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | croak 'Part number => etag hashref is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | if ref $parts_hr ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | $algorithm = lc( $algorithm // $EMPTY ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$algorithm // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$algorithm // $Amazon::S3::Bucket::EMPTY
$algorithm
$Amazon::S3::Bucket::EMPTY
Truth table0%0/3
A // B
A= $algorithmB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # The complete command requires sending a block of xml containing all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # the part numbers and their associated etags (returned from the upload) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $content = _create_multipart_upload_request( $parts_hr, $algorithm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $self->logger->debug("content: \n$content"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $md5 = md5($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my $md5_base64 = encode_base64($md5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | chomp $md5_base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $headers = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 'Content-MD5' => $md5_base64, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 'Content-Length' => length $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 'Content-Type' => 'application/xml', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $params = "?uploadId=${upload_id}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | method => 'POST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | path => $self->_uri($key) . $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | data => $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | sub abort_multipart_upload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abort_multipart_upload: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | my ( $self, $key, $upload_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | croak 'Object key is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | croak 'Upload id is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | if !$upload_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my $params = "?uploadId=${upload_id}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | method => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | path => $self->_uri($key) . $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | # List all the uploaded parts for an ongoing multipart upload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # It returns the block of XML returned from Amazon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | sub list_multipart_upload_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_multipart_upload_parts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my ( $self, $key, $upload_id, $headers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | croak 'Object key is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | croak 'Upload id is required' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | if !$upload_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my $params = "?uploadId=${upload_id}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | path => $self->_uri($key) . $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # Just return the XML, let the caller figure out what to do with it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | return $response->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # List all the currently active multipart upload operations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # Returns the block of XML returned from Amazon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | sub list_multipart_uploads { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_multipart_uploads: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my ( $self, $headers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | path => $self->_uri() . '?uploads', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # Just return the XML, let the caller figure out what to do with it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | return $response->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | sub head_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head_key: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my ( $self, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | return $self->get_key( $key, 'HEAD' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | sub get_key_v2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_key_v2: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my ( $self, $key, $method, $headers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | return $self->_get_key( $key, $method, undef, $headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 2 | ▶ | sub get_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_key: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 2 | my ( $key, $method, $headers, $uri_params, $verify_checksums ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2 | ▶ | if ( ref $args[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | ( $key, $method, $headers, $uri_params, $verify_checksums ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | = @{ $args[0] }{qw(key method headers uri_params verify_checksums)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 2 | ( $key, $method, $headers, $uri_params ) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | return $self->_get_key( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | filename => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | uri_params => $uri_params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | verify_checksums => $verify_checksums, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 2 | ▶ | sub _get_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_key: called CC=23 SCAR=39.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 2 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 2 | my $parameters = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | my ( $key, $method, $filename, $headers, $uri_params, $verify_checksums ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 2 | = @{$parameters}{qw(key method filename headers uri_params verify_checksums)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | ▶ | $verify_checksums //= $self->account->verify_checksums; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$verify_checksums //= $self->account->verify_checksums
MC/DC0%0/2
$verify_checksums //= $self->account->verify_checksums
$verify_checksums
$self->account->verify_checksums
Truth table33%1/3
A //= B
A= $verify_checksumsB= $self->account->verify_checksums
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | ▶ | $method //= 'GET'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$method //= "GET"
MC/DC0%0/1
$method //= "GET"
$method
Truth table50%1/2
A
A= $method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 2 | my $uri = $self->_uri($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | if ( $uri_params && keys %{$uri_params} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$uri_params and keys %{$uri_params;}
MC/DC0%0/2
$uri_params and keys %{$uri_params;}
$uri_params
keys %{$uri_params;}
Truth table33%1/3
A and B
A= $uri_paramsB= keys %{$uri_params;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | $uri .= $QUESTION_MARK . create_query_string($uri_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 2 | ▶ | if ( ref $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | $filename = ${$filename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 2 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 2 | ▶ | $headers = { %{ $headers // {} } }; # do not mutate caller's headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$headers // {}
MC/DC0%0/1
$headers // {}
$headers
Truth table50%1/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 2 | ▶ | if ( $verify_checksums && $method eq 'GET' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$verify_checksums and $method eq "GET"
MC/DC0%0/2
$verify_checksums and $method eq "GET"
$verify_checksums
$method eq "GET"
Truth table33%1/3
A and B
A= $verify_checksumsB= $method eq "GET"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 2 | $headers->{'x-amz-checksum-mode'} = 'ENABLED'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | path => $uri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 2 | my $response = $acct->_do_http( $request, $filename ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 2 | ▶ | if $response->code eq $HTTP_NOT_FOUND; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 2 | $acct->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 2 | my $etag = $response->header('ETag'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 2 | ▶ | if ($etag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $etag =~ s/^"//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | $etag =~ s/"$//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 2 | my %checksums; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 2 | foreach my $header ( $response->headers->header_field_names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 6 | ▶ | if ( $header =~ /\Ax-amz-checksum-(.+)\z/ixsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 2 | my $algorithm = lc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 2 | ▶ | if ( $algorithm ne 'type' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 1 | $checksums{$algorithm} = $response->header($header); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 2 | ▶ | my $retval = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition36%4/11
$response->content_length || 0
$response->content // $Amazon::S3::Bucket::EMPTY
$response->header('Content-Range') || $Amazon::S3::Bucket::EMPTY
$response->header('Last-Modified') || $Amazon::S3::Bucket::EMPTY
MC/DC0%0/1
$response->content_length || 0
$response->content_length
MC/DC0%0/2
$response->content // $Amazon::S3::Bucket::EMPTY
$response->content
$Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$response->header('Content-Range') || $Amazon::S3::Bucket::EMPTY
$response->header('Content-Range')
$Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$response->header('Last-Modified') || $Amazon::S3::Bucket::EMPTY
$response->header('Last-Modified')
$Amazon::S3::Bucket::EMPTY
Truth table50%1/2
A
A= $response->content_length
Truth table33%1/3
A // B
A= $response->contentB= $Amazon::S3::Bucket::EMPTY
Truth table33%1/3
A || B
A= $response->header('Content-Range')B= $Amazon::S3::Bucket::EMPTY
Truth table33%1/3
A || B
A= $response->header('Last-Modified')B= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | content_length => ( $response->content_length || 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | content_type => scalar $response->content_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | etag => $etag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | value => ( $response->content // $EMPTY ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | content_range => ( $response->header('Content-Range') || $EMPTY ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | last_modified => ( $response->header('Last-Modified') || $EMPTY ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | checksums => \%checksums, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | checksum_type => scalar $response->header('x-amz-checksum-type'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 2 | ▶ | if ( $verify_checksums && $method eq 'GET' && $response->code ne $HTTP_PARTIAL_CONTENT ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$verify_checksums and $method eq "GET" and $response->code ne $Amazon::S3::Bucket::HTTP_PARTIAL_CONTENT
$verify_checksums and $method eq "GET"
MC/DC0%0/3
$verify_checksums and $method eq "GET" and $response->code ne $Amazon::S3::Bucket::HTTP_PARTIAL_CONTENT
$verify_checksums
$method eq "GET"
$response->code ne $Amazon::S3::Bucket::HTTP_PARTIAL_CONTENT
Truth table25%1/4
A and B and C
A= $verify_checksumsB= $method eq "GET"C= $response->code ne $Amazon::S3::Bucket::HTTP_PARTIAL_CONTENT
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | $self->_verify_checksums( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | checksums => $retval->{checksums}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | checksum_type => $retval->{checksum_type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | filename => $filename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | data => $retval->{value}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 1 | foreach my $header ( $response->headers->header_field_names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 2 | ▶ | next if $header !~ /x-amz-meta-/ixsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | $retval->{ lc $header } = $response->header($header); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 7 | ▶ | sub _verify_checksums { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verify_checksums: called CC=10 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 7 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 7 | my $parameters = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | my ( $checksums, $checksum_type, $filename, $data ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 7 | = @{$parameters}{qw(checksums checksum_type filename data)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | return $TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 7 | ▶ | if !$checksums || !keys %{$checksums}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$checksums and keys %{$checksums;}
MC/DC50%1/2
$checksums and keys %{$checksums;}
$checksums
keys %{$checksums;}
Truth table66%2/3
A and B
A= $checksumsB= keys %{$checksums;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 6 | ▶ | return $TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$checksum_type // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$checksum_type // $Amazon::S3::Bucket::EMPTY
$checksum_type
$Amazon::S3::Bucket::EMPTY
Truth table33%1/3
A // B
A= $checksum_typeB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | if ( $checksum_type // $EMPTY ) ne 'FULL_OBJECT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 5 | my $checksum_types = $self->account->checksum_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 5 | foreach my $algorithm ( keys %{$checksums} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 5 | ▶ | if !exists $checksum_types->{$algorithm}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 4 | my %digest_parameters; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 4 | ▶ | if ( defined $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $digest_parameters{filename} = $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 4 | ▶ | $digest_parameters{data} = $data // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$data // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$data // $Amazon::S3::Bucket::EMPTY
$data
$Amazon::S3::Bucket::EMPTY
Truth table33%1/3
A // B
A= $dataB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 4 | my $digest = $checksum_types->{$algorithm}->(%digest_parameters); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 4 | my $computed = encode_base64( $digest, $EMPTY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 4 | my $expected = $checksums->{$algorithm}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 4 | ▶ | croak sprintf 'Computed and response %s checksums do not match: %s : %s', uc($algorithm), $computed, $expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | if $computed ne $expected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 3 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | sub get_key_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_key_filename: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | my ( $key, $method, $filename, $headers, $uri_params, $verify_checksums ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | if ( ref $args[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | ( $key, $method, $filename, $headers, $uri_params, $verify_checksums ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | = @{ $args[0] }{qw(key method filename headers uri_params verify_checksums)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ( $key, $method, $filename, $headers, $uri_params ) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | if ( !defined $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $filename = $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | return $self->_get_key( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | key => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | filename => \$filename, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | uri_params => $uri_params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | verify_checksums => $verify_checksums, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | # Note that in this request the bucket object is the destination you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # specify the source bucket in the key (bucket-name/source-key) or the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # header x-amz-copy-source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | sub copy_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_object: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | my $parameters = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | my ( $source, $key, $bucket, $headers_in ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | = @{$parameters}{qw(source key bucket headers)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | $headers_in //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$headers_in //= {}
MC/DC0%0/1
$headers_in //= {}
$headers_in
Truth table0%0/2
A
A= $headers_in
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my %request_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | if ( reftype($headers_in) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | %request_headers = @{$headers_in}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | elsif ( reftype($headers_in) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | %request_headers = %{$headers_in}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | croak 'headers must be hash or array' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $headers_in or builtin::reftype($headers_in) ne "HASH"
MC/DC0%0/2
not ref $headers_in or builtin::reftype($headers_in) ne "HASH"
not ref $headers_in
builtin::reftype($headers_in) ne "HASH"
Truth table0%0/3
not(A) or B
A= not ref $headers_inB= builtin::reftype($headers_in) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | if !ref($headers_in) || reftype($headers_in) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | croak 'source or x-amz-copy-source must be specified' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | if !$source && !exists $request_headers{'x-amz-copy-source'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$source or exists $request_headers{"x-amz-copy-source"}
MC/DC0%0/2
$source or exists $request_headers{"x-amz-copy-source"}
$source
exists $request_headers{"x-amz-copy-source"}
Truth table0%0/3
A or B
A= $sourceB= exists $request_headers{"x-amz-copy-source"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | ▶ | croak 'no key' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | if !$key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | my $acct = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | $bucket //= $self->bucket(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$bucket //= $self->bucket
MC/DC0%0/2
$bucket //= $self->bucket
$bucket
$self->bucket
Truth table0%0/3
A //= B
A= $bucketB= $self->bucket
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | if ( !$request_headers{'x-amz-copy-source'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | $request_headers{'x-amz-copy-source'} = sprintf '%s/%s', $bucket, urlencode($source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | $request_headers{'x-amz-tagging-directive'} //= 'COPY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$request_headers{"x-amz-tagging-directive"} //= "COPY"
MC/DC0%0/1
$request_headers{"x-amz-tagging-directive"} //= "COPY"
$request_headers{"x-amz-tagging-directive"}
Truth table0%0/2
A
A= $request_headers{"x-amz-tagging-directive"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | $key = $self->_uri($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | my $request = $acct->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | path => $key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | headers => \%request_headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my $response = $acct->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | if ( $response->code !~ /\A2\d{2}\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | $acct->_remember_errors( $response->content, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | croak $response->status_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | return $acct->_xpc_of_content( $response->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | sub delete_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_key: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | my ( $self, $key, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | croak 'must specify key' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $key and length $key
MC/DC0%0/2
not $key and length $key
not $key
length $key
Truth table0%0/3
not(A) and B
A= not $keyB= length $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | if !$key && length $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | my $path = $self->_uri($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | if ($version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $path = '?versionId=' . $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | return $account->send_request_expect_nothing( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | { method => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | headers => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | sub _format_delete_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_delete_keys: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | if ( ref $args[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | ▶ | if ( reftype( $args[0] ) eq 'ARRAY' ) { # list of keys, no version ids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | foreach my $key ( @{ $args[0] } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | if ( ref($key) && reftype($key) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $key and builtin::reftype($key) eq "HASH"
MC/DC0%0/2
ref $key and builtin::reftype($key) eq "HASH"
ref $key
builtin::reftype($key) eq "HASH"
Truth table0%0/3
A and B
A= ref $keyB= builtin::reftype($key) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | push @keys, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | Key => [ $key->{Key} ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | defined $key->{VersionId} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | ▶ | ? ( VersionId => [ $key->{VersionId} ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | else { # array of keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | push @keys, { Key => [$key], }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | elsif ( reftype( $args[0] ) eq 'CODE' ) { # sub that returns key, version id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | while ( my (@object) = $args[0]->() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | ▶ | last if !@object || !defined $object[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@object and defined $object[0]
MC/DC0%0/2
@object and defined $object[0]
@object
defined $object[0]
Truth table0%0/3
A and B
A= @objectB= defined $object[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | push @keys, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | Key => [ $object[0] ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | defined $object[1] ? ( VersionId => [ $object[1] ] ) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | else { # list of keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | croak 'argument must be array or list'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | elsif (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | @keys = map { { Key => [$_] } } @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | croak 'must specify keys'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | ▶ | croak 'must not exceed ' . $MAX_DELETE_KEYS . ' keys' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | if @keys > $MAX_DELETE_KEYS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | return \@keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | # @args => list of keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | # $args[0] => array of hashes (Key, [VersionId]) VersionId is optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | # $args[0] => array of scalars (keys) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | # $args[0] => code reference that returns key, version id or empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # $args[0] => hash ({ quiet => 1, keys => $keys}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | # Throws exception if no keys or in wrong format... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | ▶ | sub delete_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_keys: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | my ( $keys, $quiet_mode, $headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | ▶ | if ( ref $args[0] && reftype( $args[0] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $args[0] and builtin::reftype($args[0]) eq "HASH"
MC/DC0%0/2
ref $args[0] and builtin::reftype($args[0]) eq "HASH"
ref $args[0]
builtin::reftype($args[0]) eq "HASH"
Truth table0%0/3
A and B
A= ref $args[0]B= builtin::reftype($args[0]) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ( $keys, $quiet_mode, $headers ) = @{ $args[0] }{qw(keys quiet headers)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | $keys = _format_delete_keys($keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | $keys = _format_delete_keys(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | if ( defined $quiet_mode ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | $quiet_mode = $quiet_mode ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | $quiet_mode = 'false'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | my $content = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | xmlns => $S3_XMLNS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | Quiet => [$quiet_mode], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | Object => $keys, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | my $xml_content = XMLout( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | RootName => 'Delete', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | XMLDecl => $XMLDECL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | my $md5 = md5($xml_content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | my $md5_base64 = encode_base64($md5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | chomp $md5_base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | $headers //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$headers //= {}
MC/DC0%0/1
$headers //= {}
$headers
Truth table0%0/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | $headers->{'Content-MD5'} = $md5_base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | return $account->send_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | { method => 'POST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | path => $self->_uri() . '?delete', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | data => $xml_content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | ▶ | sub delete_bucket { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_bucket: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | ▶ | croak 'Unexpected arguments' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | if @_ > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | return $self->account->delete_bucket($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | ▶ | sub list_v2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_v2: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my ( $self, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | $conf ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | $conf->{bucket} = $self->bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | $conf->{'list-type'} = '2'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | if ( $conf->{'marker'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $conf->{'continuation-token'} = delete $conf->{'marker'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | return $self->list($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | my ( $self, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | $conf ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | $conf->{bucket} = $self->bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | return $self->account->list_bucket($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | sub list_all_v2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_all_v2: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | my ( $self, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | ▶ | $conf //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf //= {}
MC/DC0%0/1
$conf //= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | $conf->{bucket} = $self->bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | return $self->account->list_bucket_all_v2($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | sub list_all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_all: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | my ( $self, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | ▶ | $conf //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf //= {}
MC/DC0%0/1
$conf //= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | $conf->{bucket} = $self->bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | return $self->account->list_bucket_all($conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | sub get_acl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_acl: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | my ( $self, $key, $headers ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | ▶ | my $request = $account->_make_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$headers // {}
MC/DC0%0/1
$headers // {}
$headers
Truth table0%0/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | path => $self->_uri($key) . '?acl=', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | headers => $headers // {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | my $old_redirectable = $account->ua->requests_redirectable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | $account->ua->requests_redirectable( [] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $response = $account->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | if ( $response->code =~ /^30/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my $xpc = $account->_xpc_of_content( $response->content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | my $uri = URI->new( $response->header('location') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | my $old_host = $account->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | $account->host( $uri->host ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | $request = $account->_make_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | { region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | path => $uri->path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | headers => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | $response = $account->_do_http($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | $account->ua->requests_redirectable($old_redirectable); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | $account->host($old_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # do we test for NOT FOUND, returning undef? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | ▶ | if ( $response->code ne $HTTP_NOT_FOUND ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | $account->_croak_if_response_error($response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | $content = $response->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | ▶ | sub set_acl { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_acl: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | my ( $self, $conf ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | ▶ | $conf //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$conf //= {}
MC/DC0%0/1
$conf //= {}
$conf
Truth table0%0/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | croak 'need either acl_xml or acl_short' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | ▶ | if !$conf->{acl_xml} && !$conf->{acl_short}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$conf->{"acl_xml"} or $conf->{"acl_short"}
MC/DC0%0/2
$conf->{"acl_xml"} or $conf->{"acl_short"}
$conf->{"acl_xml"}
$conf->{"acl_short"}
Truth table0%0/3
A or B
A= $conf->{"acl_xml"}B= $conf->{"acl_short"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | croak 'cannot provide both acl_xml and acl_short' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | ▶ | if $conf->{acl_xml} && $conf->{acl_short}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$conf->{"acl_xml"} and $conf->{"acl_short"}
MC/DC0%0/2
$conf->{"acl_xml"} and $conf->{"acl_short"}
$conf->{"acl_xml"}
$conf->{"acl_short"}
Truth table0%0/3
A and B
A= $conf->{"acl_xml"}B= $conf->{"acl_short"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | my $path = $self->_uri( $conf->{key} ) . '?acl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | my $headers = $conf->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | ▶ | if ( $conf->{acl_short} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | ▶ | $headers->{'x-amz-acl'} //= $conf->{acl_short}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$headers->{"x-amz-acl"} //= $conf->{"acl_short"}
MC/DC0%0/2
$headers->{"x-amz-acl"} //= $conf->{"acl_short"}
$headers->{"x-amz-acl"}
$conf->{"acl_short"}
Truth table0%0/3
A //= B
A= $headers->{"x-amz-acl"}B= $conf->{"acl_short"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | ▶ | my $xml = $conf->{acl_xml} // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$conf->{"acl_xml"} // $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$conf->{"acl_xml"} // $Amazon::S3::Bucket::EMPTY
$conf->{"acl_xml"}
$Amazon::S3::Bucket::EMPTY
Truth table0%0/3
A // B
A= $conf->{"acl_xml"}B= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | $headers->{'Content-Length'} = length $xml; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | return $account->send_request_expect_nothing( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | { method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | data => $xml, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | region => $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | sub get_location_constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_location_constraint: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | my $parameters = get_parameters(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | my ( $bucket, $headers, $region ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | = @{$parameters}{qw(bucket headers region)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | my $account = $self->account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | $bucket //= $self->bucket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$bucket //= $self->bucket
MC/DC0%0/2
$bucket //= $self->bucket
$bucket
$self->bucket
Truth table0%0/3
A //= B
A= $bucketB= $self->bucket
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | my $location = $account->send_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$region // $self->region
MC/DC0%0/2
$region // $self->region
$region
$self->region
Truth table0%0/3
A // B
A= $regionB= $self->region
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | { region => $region // $self->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | path => $bucket . '/?location=', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | headers => $headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | ▶ | return $location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | if $location; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | ▶ | croak $account->errstr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | if $account->_remember_errors($location); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | sub last_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_response: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | return $self->account->last_response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | sub err { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
err: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | return $self->account->err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | sub errstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errstr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | return $self->account->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | return $self->account->error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 1 | ▶ | sub _content_sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_content_sub: called CC=5 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 1 | my ( $filename, $buffer_size ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 1 | my $stat = stat $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 1 | my $remaining = $stat->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 1 | ▶ | my $blksize = $stat->blksize || $buffer_size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$stat->blksize || $buffer_size
MC/DC0%0/2
$stat->blksize || $buffer_size
$stat->blksize
$buffer_size
Truth table33%1/3
A || B
A= $stat->blksizeB= $buffer_size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 1 | ▶ | croak "$filename not a readable file with fixed size" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-r $filename and $remaining
MC/DC0%0/2
-r $filename and $remaining
-r $filename
$remaining
Truth table33%1/3
A and B
A= -r $filenameB= $remaining
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | if !-r $filename || !$remaining; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 1 | ▶ | my $fh = IO::File->new( $filename, 'r' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | or croak "Could not open $filename: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 1 | $fh->binmode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | # upon retries the file is closed and we must reopen it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | ▶ | if ( !$fh->opened ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | ▶ | $fh = IO::File->new( $filename, 'r' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | or croak "Could not open $filename: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | $fh->binmode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $remaining = $stat->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | my $read = $fh->read( $buffer, $blksize ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | ▶ | if ( !$read ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | ▶ | croak "Error while reading upload content $filename ($remaining remaining) $OS_ERROR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Amazon::S3::Bucket::OS_ERROR and $remaining
MC/DC0%0/2
$Amazon::S3::Bucket::OS_ERROR and $remaining
$Amazon::S3::Bucket::OS_ERROR
$remaining
Truth table0%0/3
A and B
A= $Amazon::S3::Bucket::OS_ERRORB= $remaining
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | if $OS_ERROR and $remaining; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | ▶ | $fh->close # otherwise, we found EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | or croak "close of upload content $filename failed: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | $buffer ||= $EMPTY; # LWP expects an empty string on finish, read returns 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$buffer ||= $Amazon::S3::Bucket::EMPTY
MC/DC0%0/2
$buffer ||= $Amazon::S3::Bucket::EMPTY
$buffer
$Amazon::S3::Bucket::EMPTY
Truth table0%0/3
A ||= B
A= $bufferB= $Amazon::S3::Bucket::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | $remaining -= length $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | return $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 2 | ▶ | sub _create_multipart_upload_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_multipart_upload_request: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 2 | my ( $parts_hr, $algorithm ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 2 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | foreach my $part_num ( sort { $a <=> $b } keys %{$parts_hr} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 2 | my $part = $parts_hr->{$part_num}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 2 | my $entry = { PartNumber => $part_num, }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 2 | ▶ | if ( ref $part ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 2 | $entry->{ETag} = $part->{etag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 2 | ▶ | if ( defined $part->{checksum} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 2 | my $checksum_name = 'Checksum' . uc $algorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 2 | $entry->{$checksum_name} = $part->{checksum}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | # Legacy part_number => etag representation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | $entry->{ETag} = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 2 | push @parts, $entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 2 | return create_xml_request( { CompleteMultipartUpload => { Part => \@parts } } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||