mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-09 05:15:49 +00:00
INotify.pm - new helper poll_changes
Useful to detect file changes. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
04cba6c8c1
commit
3b671d82b1
@ -199,6 +199,16 @@ sub discard_changes {
|
|||||||
return read_file ($filename, $full);
|
return read_file ($filename, $full);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub poll_changes {
|
||||||
|
my ($filename) = @_;
|
||||||
|
|
||||||
|
poll() if $inotify; # read new inotify events
|
||||||
|
|
||||||
|
$versions->{$filename} = 0 if !defined ($versions->{$filename});
|
||||||
|
|
||||||
|
return $versions->{$filename};
|
||||||
|
}
|
||||||
|
|
||||||
sub read_file {
|
sub read_file {
|
||||||
my ($fileid, $full) = @_;
|
my ($fileid, $full) = @_;
|
||||||
|
|
||||||
@ -211,11 +221,7 @@ sub read_file {
|
|||||||
my $fd;
|
my $fd;
|
||||||
my $shadow;
|
my $shadow;
|
||||||
|
|
||||||
poll() if $inotify; # read new inotify events
|
my $cver = poll_changes($filename);
|
||||||
|
|
||||||
$versions->{$filename} = 0 if !defined ($versions->{$filename});
|
|
||||||
|
|
||||||
my $cver = $versions->{$filename};
|
|
||||||
|
|
||||||
if (my $copy = $shadowfiles->{$filename}) {
|
if (my $copy = $shadowfiles->{$filename}) {
|
||||||
if ($fd = IO::File->new ($copy, "r")) {
|
if ($fd = IO::File->new ($copy, "r")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user