line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Dir::Dumper::DigestCache::FS; |
2
|
|
|
|
|
|
|
$File::Dir::Dumper::DigestCache::FS::VERSION = '0.6.4'; |
3
|
2
|
|
|
2
|
|
98966
|
use warnings; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
593
|
use autodie; |
|
2
|
|
|
|
|
16072
|
|
|
2
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
13099
|
use parent 'File::Dir::Dumper::Base'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
136
|
use 5.012; |
|
2
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
547
|
use Class::XSAccessor accessors => { _path => '_path', }; |
|
2
|
|
|
|
|
2593
|
|
|
2
|
|
|
|
|
26
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
518
|
use File::Basename qw/ dirname /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
164
|
|
14
|
2
|
|
|
2
|
|
13
|
use File::Spec (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
15
|
2
|
|
|
2
|
|
14
|
use File::Path 2.00 qw/ make_path /; |
|
2
|
|
|
|
|
44
|
|
|
2
|
|
|
|
|
88
|
|
16
|
2
|
|
|
2
|
|
516
|
use JSON::MaybeXS (); |
|
2
|
|
|
|
|
6100
|
|
|
2
|
|
|
|
|
1020
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init |
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
2
|
|
7
|
my ( $self, $args ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $basepath = $args->{params}->{path} |
24
|
2
|
50
|
|
|
|
9
|
or die "path not specified as a parameter!"; |
25
|
2
|
|
|
|
|
25
|
$self->_path( File::Spec->catdir( $basepath, 'digests-cache-dir' ) ); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
6
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _slurp |
32
|
|
|
|
|
|
|
{ |
33
|
7
|
|
|
7
|
|
136
|
my $filename = shift; |
34
|
|
|
|
|
|
|
|
35
|
7
|
50
|
|
|
|
21
|
open my $in, '<', $filename |
36
|
|
|
|
|
|
|
or die "Cannot open '$filename' for slurping - $!"; |
37
|
|
|
|
|
|
|
|
38
|
7
|
|
|
|
|
730
|
local $/; |
39
|
7
|
|
|
|
|
161
|
my $contents = <$in>; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
39
|
close($in); |
42
|
|
|
|
|
|
|
|
43
|
7
|
|
|
|
|
463
|
return $contents; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_digests |
47
|
|
|
|
|
|
|
{ |
48
|
6
|
|
|
6
|
1
|
539
|
my ( $self, $args ) = @_; |
49
|
6
|
|
|
|
|
13
|
my $mtime = $args->{mtime}; |
50
|
6
|
|
|
|
|
17
|
my $path = File::Spec->catfile( $self->_path, @{ $args->{path} } ); |
|
6
|
|
|
|
|
73
|
|
51
|
6
|
|
|
|
|
15
|
my $cb = $args->{calc_cb}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $update = sub { |
54
|
5
|
|
|
5
|
|
21
|
open my $out, '>', $path; |
55
|
5
|
|
|
|
|
5573
|
$out->print( JSON::MaybeXS->new( canonical => 1 ) |
56
|
|
|
|
|
|
|
->encode( +{ mtime => $mtime, digests => scalar( $cb->() ) } ) |
57
|
|
|
|
|
|
|
); |
58
|
5
|
|
|
|
|
192
|
close $out; |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
2307
|
return; |
61
|
6
|
|
|
|
|
20
|
}; |
62
|
6
|
100
|
|
|
|
164
|
if ( !-f $path ) |
63
|
|
|
|
|
|
|
{ |
64
|
4
|
|
|
|
|
861
|
make_path( dirname($path) ); |
65
|
4
|
|
|
|
|
20
|
$update->(); |
66
|
|
|
|
|
|
|
} |
67
|
6
|
|
|
|
|
15
|
while (1) |
68
|
|
|
|
|
|
|
{ |
69
|
7
|
|
|
|
|
44
|
my $json = |
70
|
|
|
|
|
|
|
JSON::MaybeXS->new( canonical => 1 )->decode( _slurp($path) ); |
71
|
7
|
100
|
|
|
|
49
|
if ( $json->{mtime} == $mtime ) |
72
|
|
|
|
|
|
|
{ |
73
|
6
|
|
|
|
|
70
|
return $json->{digests}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else |
76
|
|
|
|
|
|
|
{ |
77
|
1
|
|
|
|
|
5
|
$update->(); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
|
die "Bug"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; # End of File::Dir::Dumper |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |