line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::BagIt::Role::OpenSSL; |
2
|
8
|
|
|
8
|
|
3805
|
use strict; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
268
|
|
3
|
8
|
|
|
8
|
|
45
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
256
|
|
4
|
8
|
|
|
8
|
|
3110
|
use Archive::BagIt::Role::OpenSSL::Sync; |
|
8
|
|
|
|
|
34
|
|
|
8
|
|
|
|
|
283
|
|
5
|
8
|
|
|
8
|
|
50
|
use Class::Load qw(load_class); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
416
|
|
6
|
8
|
|
|
8
|
|
64
|
use Carp qw(carp); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
334
|
|
7
|
8
|
|
|
8
|
|
43
|
use Moo::Role; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
69
|
|
8
|
8
|
|
|
8
|
|
3173
|
use namespace::autoclean; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
55
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: A role that handles plugin loading |
10
|
|
|
|
|
|
|
our $VERSION = '0.095'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'async_support' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
builder => '_check_async_support', |
16
|
|
|
|
|
|
|
predicate => 1, |
17
|
|
|
|
|
|
|
lazy => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _check_async_support { |
21
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
22
|
0
|
0
|
|
|
|
0
|
if (! exists $INC{'IO/Async.pm'}) { |
23
|
0
|
|
|
|
|
0
|
carp "Module 'IO::Async' not available, disable async support"; |
24
|
0
|
|
|
|
|
0
|
$self->bagit->use_async(0); |
25
|
0
|
|
|
|
|
0
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
0
|
load_class('IO::Async'); |
28
|
0
|
|
|
|
|
0
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _get_hash_string_sync { |
34
|
549
|
|
|
549
|
|
983
|
my ($self, $fh, $blksize)=@_; |
35
|
549
|
|
|
|
|
10735
|
my $obj = Archive::BagIt::Role::OpenSSL::Sync->new( name => $self->name); |
36
|
549
|
|
|
|
|
16838
|
return $obj->calc_digest($fh, $blksize); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _get_hash_string_async { |
40
|
10
|
|
|
10
|
|
25
|
my ($self, $fh, $blksize) = @_; |
41
|
10
|
|
|
|
|
13
|
my $result; |
42
|
10
|
50
|
|
|
|
27
|
if ($self->has_async_support()) { |
43
|
0
|
|
|
|
|
0
|
my $class = 'Archive::BagIt::Role::OpenSSL::Async'; |
44
|
0
|
0
|
|
|
|
0
|
load_class($class) or croak("could not load class $class"); |
45
|
0
|
|
|
|
|
0
|
my $obj = $class->new(name => $self->name); |
46
|
0
|
|
|
|
|
0
|
$result = $obj->calc_digest($fh, $blksize); |
47
|
|
|
|
|
|
|
} else { |
48
|
10
|
|
|
|
|
19
|
$result = $self->_get_hash_string_sync($fh, $blksize); |
49
|
|
|
|
|
|
|
} |
50
|
10
|
|
|
|
|
37
|
return $result; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub get_hash_string { |
55
|
549
|
|
|
549
|
1
|
1070
|
my ($self, $fh) = @_; |
56
|
549
|
|
|
|
|
1320
|
my $blksize = $self->get_optimal_bufsize($fh); |
57
|
549
|
|
|
|
|
1389
|
my $bagobj = $self->bagit; |
58
|
549
|
100
|
|
|
|
11940
|
if ($bagobj->use_async) { |
59
|
10
|
|
|
|
|
80
|
return $self->_get_hash_string_async($fh, $blksize); |
60
|
|
|
|
|
|
|
} |
61
|
539
|
|
|
|
|
4114
|
return $self->_get_hash_string_sync($fh, $blksize); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
8
|
|
|
8
|
|
3824
|
no Moo; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
32
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |