line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::ChangeNotify::Watcher::Default; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
4896
|
use strict; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
310
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
84
|
|
5
|
3
|
|
|
3
|
|
649
|
use namespace::autoclean; |
|
3
|
|
|
|
|
45943
|
|
|
3
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.30'; |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1324
|
use Time::HiRes qw( sleep ); |
|
3
|
|
|
|
|
4365
|
|
|
3
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
1718
|
use Moo; |
|
3
|
|
|
|
|
24656
|
|
|
3
|
|
|
|
|
17
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'File::ChangeNotify::Watcher'; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
0
|
15
|
sub sees_all_events {0} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
18
|
138
|
|
|
138
|
|
378
|
sub _always_requires_mtime {1} |
19
|
|
|
|
|
|
|
## use critic |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub BUILD { |
22
|
25
|
|
|
25
|
0
|
2695
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
25
|
|
|
|
|
97
|
$self->_set_map( $self->_current_map ); |
25
|
|
|
|
|
|
|
|
26
|
25
|
|
|
|
|
815
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub wait_for_events { |
30
|
12
|
|
|
12
|
0
|
4062
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
12
|
|
|
|
|
26
|
while (1) { |
33
|
12
|
|
|
|
|
32
|
my @events = $self->_interesting_events; |
34
|
12
|
50
|
|
|
|
133
|
return @events if @events; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
sleep $self->sleep_interval; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _interesting_events { |
41
|
29
|
|
|
29
|
|
52
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
29
|
|
|
|
|
58
|
my @interesting; |
44
|
|
|
|
|
|
|
|
45
|
29
|
|
|
|
|
90
|
my $old_map = $self->_map; |
46
|
29
|
|
|
|
|
92
|
my $new_map = $self->_current_map; |
47
|
|
|
|
|
|
|
|
48
|
29
|
|
|
|
|
75
|
for my $path ( sort keys %{$old_map} ) { |
|
29
|
|
|
|
|
168
|
|
49
|
63
|
100
|
|
|
|
856
|
if ( !exists $new_map->{$path} ) { |
50
|
6
|
100
|
|
|
|
27
|
if ( $old_map->{$path}{is_dir} ) { |
51
|
2
|
|
|
|
|
11
|
$self->_remove_directory($path); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
6
|
|
|
|
|
213
|
push @interesting, $self->event_class->new( |
55
|
|
|
|
|
|
|
path => $path, |
56
|
|
|
|
|
|
|
type => 'delete', |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
|
|
|
|
|
|
# If we're tracking stat info changes then we get the old & new |
61
|
|
|
|
|
|
|
# stat info back in @extra. No need to stat the path _again_. |
62
|
57
|
|
|
|
|
147
|
my ( $modified, @extra ) |
63
|
|
|
|
|
|
|
= $self->_path_was_modified( $path, $old_map, $new_map ); |
64
|
57
|
100
|
|
|
|
151
|
if ($modified) { |
65
|
14
|
|
|
|
|
66
|
push @interesting, $self->event_class->new( |
66
|
|
|
|
|
|
|
path => $path, |
67
|
|
|
|
|
|
|
type => 'modify', |
68
|
|
|
|
|
|
|
@extra, |
69
|
|
|
|
|
|
|
$self->_modify_event_maybe_content_changes( |
70
|
|
|
|
|
|
|
$path, $old_map, $new_map |
71
|
|
|
|
|
|
|
), |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
29
|
|
|
|
|
832
|
for my $path ( sort grep { !exists $old_map->{$_} } keys %{$new_map} ) { |
|
71
|
|
|
|
|
191
|
|
|
29
|
|
|
|
|
92
|
|
78
|
14
|
|
|
|
|
490
|
push @interesting, $self->event_class->new( |
79
|
|
|
|
|
|
|
path => $path, |
80
|
|
|
|
|
|
|
type => 'create', |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
29
|
|
|
|
|
4937
|
$self->_set_map($new_map); |
85
|
|
|
|
|
|
|
|
86
|
29
|
|
|
|
|
876
|
return @interesting; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _path_was_modified { |
90
|
57
|
|
|
57
|
|
105
|
my $self = shift; |
91
|
57
|
|
|
|
|
85
|
my $path = shift; |
92
|
57
|
|
|
|
|
81
|
my $old_map = shift; |
93
|
57
|
|
|
|
|
79
|
my $new_map = shift; |
94
|
|
|
|
|
|
|
|
95
|
57
|
|
|
|
|
94
|
my $old_entry = $old_map->{$path}; |
96
|
57
|
|
|
|
|
105
|
my $new_entry = $new_map->{$path}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# If it's a file and the mtime or size changed we know it's been modified |
99
|
|
|
|
|
|
|
# in some way. |
100
|
|
|
|
|
|
|
return 1 |
101
|
|
|
|
|
|
|
if !$old_entry->{is_dir} |
102
|
|
|
|
|
|
|
&& ( $old_entry->{stat}{mtime} != $new_entry->{stat}{mtime} |
103
|
57
|
100
|
100
|
|
|
245
|
|| $old_entry->{size} != $new_entry->{size} ); |
|
|
|
100
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
47
|
100
|
|
|
|
139
|
if ( |
106
|
|
|
|
|
|
|
my @attrs = $self->_modify_event_maybe_file_attribute_changes( |
107
|
|
|
|
|
|
|
$path, $old_map, $new_map |
108
|
|
|
|
|
|
|
) |
109
|
|
|
|
|
|
|
) { |
110
|
|
|
|
|
|
|
|
111
|
4
|
|
|
|
|
17
|
return ( 1, @attrs ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
43
|
|
|
|
|
111
|
return 0; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# ABSTRACT: Fallback default watcher subclass |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |