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