FU: Simplify --monitor file change detection

This changes the way that file changes are detected. The upside is that
it now correctly detects changes that happened after the code has loaded
but before the first request came in, the downside is that it now gets
stuck on reloading when a file has a future mtime.
This commit is contained in:
Yorhel 2025-05-27 09:30:46 +02:00
parent fd8332601b
commit f8cd8a6d8c

7
FU.pm
View file

@ -217,17 +217,12 @@ sub monitor_path { push @monitor_paths, @_ }
sub monitor_check :prototype(&) { $monitor_check = $_[0] } sub monitor_check :prototype(&) { $monitor_check = $_[0] }
sub _monitor { sub _monitor {
state %data;
return 1 if $monitor_check && $monitor_check->(); return 1 if $monitor_check && $monitor_check->();
require File::Find; require File::Find;
eval { eval {
File::Find::find({ File::Find::find({
wanted => sub { wanted => sub { die if (-M) < 0 },
my $m = (stat)[9];
$data{$_} //= $m;
die if $m > $data{$_};
},
no_chdir => 1 no_chdir => 1
}, grep -e, $scriptpath, values %INC, @monitor_paths); }, grep -e, $scriptpath, values %INC, @monitor_paths);
0 0