Skip Menu |

This queue is for tickets about the Linux-Inotify2 CPAN distribution.

Report information
The Basics
Id: 128944
Status: new
Priority: 0/
Queue: Linux-Inotify2

Owner: Nobody in particular
Requestors: colin.evans.parkstone [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: Enhancement request: $watch->disable , $watch->enable
Date: Wed, 27 Mar 2019 00:57:49 +0000
To: bug-Linux-Inotify2 [...]
From: incansvl <colin.evans.parkstone [...]>
Download (untitled) / with headers
text/plain 2.6k
OS: Debian Buster/Sid Perl: v5.28.1 Module: Linux::Inotify2 v2.1 _Enhancement request: /$watch->disable/ , /$watch->enable/_ Hi,     This may be me misunderstanding what the current API can do, but if this _is_ a limitation currently, I would like to request this as a possible enhancement. *Scenario* I have written a small script using Linux::Inotify2 (and based closely on the example in the documentation) to "catch" /.m3u/ playlist files that are created on a PC client and saved to a shared folder on my home server. When a playlist file is written the script checks the format and if it is "PC style" (with a utf8 Byte Order Mark and/or Windows pathnames) it rewrites it to Linux format so the media server running on the server will be able to read the playlist. *Issue* Because the script uses sed to edit the file in-place (which in practice means sed writes to a tmp file then renames the tmp file to replace the original), the processing re-triggers an Inotify event, so the script triggers itself. This doesn't cause an endless loop, as the script will exit when it sees the second file is already in Linux format, but it does mean every file saves causes TWO events, when only one is needed. Ideally, I want to be able to temporarily /disable /the watcher while the event handler is running, then re-enable it after the file is processed. *Discussion* The example code <> on meta::cpan shows the /$watch->cancel/ function, but as I understand it that destroys the watch so it can't be used again. It looks as if to achieve what I want with the current API would mean re-factoring the code to something like- |$inotify||->watch (||"/etc/passwd"||, IN_ACCESS, ||sub| |{||||| |my $e = shift;| |||$e||->w->cancel; # cancel this watch to avoid looping| || |do_my_processing();| || |# re-create a new watch from scratch | || |$inotify||->watch (||"/etc/passwd"||, IN_ACCESS, ||sub| |{||||||| | my $e = shift;||| |||$e||->w->cancel;||| |do_my_processing();||| |});||||| |||| |});| || |(i'm not a great programmer, so excuse me if this code is bad, or maybe wouldn't work at all?)| || Much nicer would be- |$inotify||->watch (||"/etc/passwd"||, IN_ACCESS, ||sub| |{||||| |my $e = shift;| |||$e||->w->disable;                # "silence" this watch temporarily to avoid looping| |   do_my_processing();| |$e->w->enable;                 # re-enable monitoring | |||||| |||| |});| | | | | |Does that make sense, or can the API already do this in a way I have not understood?| | | |Thanks for what is already a very good module !| | | |Regards: incansvl | || ||

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to