Code Monkey home page Code Monkey logo

file-changenotify's Introduction

NAME

File::ChangeNotify - Watch for changes to files, cross-platform style

VERSION

version 0.31

SYNOPSIS

use File::ChangeNotify;

my $watcher =
    File::ChangeNotify->instantiate_watcher
        ( directories => [ '/my/path', '/my/other' ],
          filter      => qr/\.(?:pm|conf|yml)$/,
        );

if ( my @events = $watcher->new_events ) { ... }

# blocking
while ( my @events = $watcher->wait_for_events ) { ... }

DESCRIPTION

This module provides an API for creating a File::ChangeNotify::Watcher subclass that will work on your platform.

Most of the documentation for this distro is in File::ChangeNotify::Watcher.

METHODS

This class provides the following methods:

File::ChangeNotify->instantiate_watcher(...)

This method looks at each available subclass of File::ChangeNotify::Watcher and instantiates the first one it can load, using the arguments you provided.

It always tries to use the File::ChangeNotify::Watcher::Default class last, on the assumption that any other class that is available is a better option.

File::ChangeNotify->usable_classes

Returns a list of all the loadable File::ChangeNotify::Watcher subclasses except for File::ChangeNotify::Watcher::Default, which is always usable.

SUPPORT

Bugs may be submitted at http://rt.cpan.org/Public/Dist/Display.html?Name=File-ChangeNotify or via email to [email protected].

I am also usually active on IRC as 'autarch' on irc://irc.perl.org.

SOURCE

The source code repository for File-ChangeNotify can be found at https://github.com/houseabsolute/File-ChangeNotify.

DONATIONS

If you'd like to thank me for the work I've done on this module, please consider making a "donation" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer.

Please note that I am not suggesting that you must do this in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me.

Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together).

To donate, log into PayPal and send money to [email protected], or use the button at http://www.urth.org/~autarch/fs-donation.html.

AUTHOR

Dave Rolsky [email protected]

CONTRIBUTORS

COPYRIGHT AND LICENSE

This software is Copyright (c) 2009 - 2019 by Dave Rolsky.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.

file-changenotify's People

Contributors

arc avatar autarch avatar karenetheridge avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

file-changenotify's Issues

Bug in File::ChangeNotify::Watcher::Inotify __build__mask

Migrated from rt.cpan.org #52325 (status was 'open')

Requestors:

Attachments:

From [email protected] on 2009-12-01 16:42:39
:

Package: File-ChangeNotify-0.09
Perl: 5.10.0
os: Linux ubuntu 2.6.27-7-generic

In File::ChangeNotify::Watcher::Inotify sub __build__mask I believe that
IN_MOVED_TO should be included in $mask. Otherwise renaming/moving files
into a watched directory are not picked up.

Curtis Fletcher
Software Developer

tuscany networks Limited
Tuscany House, White Hart Lane, Basingstoke, RG21 4AF

Tel: 01256 303 726 Fax: 01256 303 701

www.tuscanynetworks.com

Important Notice
The information contained in or attached to this email is intended only for
the use of the correct addressee(s). If you are not the intended recipient,
or a person responsible for delivering it to the intended recipient, you are
not authorised to and must not disclose, copy, distribute, or retain this
message or any part of it.
It may contain information which is confidential and/or covered by legal
professional or other privilege (or other rules or laws with similar effect
in jurisdictions outside England and Wales). The views expressed in this
email are those of the author and not necessarily the views of the company,
its directors, officers or employees and we make no representation or accept
any liability for its accuracy or completeness unless expressly stated to
the contrary. The company will not be liable for direct, special, indirect
or consequential damages arising from alteration of the contents of this
message by a third party or as a result of any virus being passed on. The
company has implemented virus detection systems to minimise the risk of
passing on viruses. The company records all e-mail messages sent to and from
this address and reserves the right to monitor and examine content for the
purposes of training, quality control and for investigating or detecting any
unauthorised use of its system and for ensuring its effective operation.
tuscany networks is registered in England, company number 320 3561.

Cannot install easily on Debian Etch

Migrated from rt.cpan.org #47814 (status was 'stalled')

Requestors:

From [email protected] on 2009-07-12 20:39:38
:

On Debian Etch:

Linux xenoscience.net 2.6.24-etchnhalf.1-686 #1 SMP Mon Sep 8 06:19:11
UTC 2008 i686 GNU/Linux

CPAN installation gives:

Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/all.t ........... Could not load class
(File::ChangeNotify::Watcher::Inotify) because : Bareword
"IN_DONT_FOLLOW" not allowed while "strict subs" in use at
/home/krs/.cpan/build/File-ChangeNotify-0.07-fn9g3w/blib/lib/File/ChangeNotify/Watcher/Inotify.pm
line 109.
BEGIN not safe after errors--compilation aborted at
/home/krs/.cpan/build/File-ChangeNotify-0.07-fn9g3w/blib/lib/File/ChangeNotify/Watcher/Inotify.pm
line 192.
Compilation failed in require at /usr/local/lib/perl/5.8.8/Class/MOP.pm
line 134.
at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 119
Class::MOP::load_first_existing_class('File::ChangeNotify::Watcher::Inotify') called at /usr/local/lib/perl/5.8.8/Class/MOP.pm line 140
Class::MOP::load_class('File::ChangeNotify::Watcher::Inotify') called
at
/home/krs/.cpan/build/File-ChangeNotify-0.07-fn9g3w/blib/lib/File/ChangeNotify.pm
line 38
eval {...} called at
/home/krs/.cpan/build/File-ChangeNotify-0.07-fn9g3w/blib/lib/File/ChangeNotify.pm
line 38
File::ChangeNotify::_try_load('File::ChangeNotify::Watcher::Inotify')
called at
/home/krs/.cpan/build/File-ChangeNotify-0.07-fn9g3w/blib/lib/File/ChangeNotify.pm
line 31
File::ChangeNotify::usable_classes('File::ChangeNotify') called at
t/lib/File/ChangeNotify/TestHelper.pm line 20
File::ChangeNotify::TestHelper::run_tests() called at t/all.t line 8
t/all.t ........... Dubious, test returned 9 (wstat 2304, 0x900)
No subtests run
t/kwalitee.t ...... skipped: This test is only run for the module author
t/pod-coverage.t .. skipped: This test is only run for the module author
t/pod.t ........... skipped: This test is only run for the module author

Test Summary Report

t/all.t (Wstat: 2304 Tests: 0 Failed: 0)
Non-zero exit status: 9
Parse errors: No plan found in TAP output
Files=4, Tests=0, 2 wallclock secs ( 0.12 usr 0.03 sys + 2.02 cusr
0.13 csys = 2.30 CPU)
Result: FAIL
Failed 1/4 test programs. 0/0 subtests failed.So, eventually I got this
to work with Linux::Inotify2 1.01 and
make: *** [test_dynamic] Error 255
DROLSKY/File-ChangeNotify-0.07.tar.gz
/usr/bin/make test -- NOT OK

Note that dependency Linux::Inotify2's Inotify.xs also would not compile
initially as it wanted to include '/usr/include/sys/inotify.h' which I
found in '/usr/include/linux/inotify.h'.

So, eventually I got this to work with Linux::Inotify2 1.01 and by
installing Debian package libinotifytools0-dev, then reinstalling your
module via CPAN.

So...figured you'd like to know it took some doing.
SSF

'wrong' event being caught for file creation in File::ChangeNotify::Watcher::Inotify

Migrated from rt.cpan.org #109660 (status was 'open')

Requestors:

From [email protected] on 2015-11-25 13:35:49
:

Hi there Mr Rolsky,

I have been using the File::ChangeNotify module in some recent work for
my employer.

I have tried using both File::ChangeNotify::Watcher::Default and
File::ChangeNotify::Watcher::Inotify. This problem affects both in a
sense, but is really an issue with File::ChangeNotify::Watcher::Inotify.

Some of the files I was working with were on the bulky side but not
humunguous - ca. 220MB. But I was finding that when I wrote code to
check the file size after the watcher had detected it, these files were
failing a validity tests that they should be over 66 lines. We came to
realise that the watcher was firing the code before its contents had
finished being copied.

Our lead dev figured out that the event you are picking up in
::Watcher::Inotify via Linux::Inotify2, IN_CREATE, was the issue. This
event gets fired at the beginning of file creation. Hence, before the
contents start being written.

I tried going back to just using ::Watcher::Default, but the same issues
were occurring there, too. Of course, this is unrelated to the inotify
event, as inotify is not involved.

In order to get the desired functionality, I simply replaced all
instances of 'IN_CREATE' in the ::Watcher::Inotify code with
'IN_CLOSE_WRITE'. (I also made some POD changes and renamed the changed
module). Now that I am watching for this event, I don't seem to be
having any more problems with large files appearing to have zero lines.

This should also address some of the issues mentioned in ticket #52325
regarding being able to run code at the end of a file transfer process.

However, IN_CLOSE_WRITE also gets triggered when an existing file is
overwritten, but not when renamed or moved. For my purposes, this was
appropriate. But it does stretch the concept of file creation a little.

Would you consider simply changing ::Watcher::Inotify to watch for this
event in place of IN_CREATE?

Thanks & regards,
Ludovic Tolhurst-Cleaver

Perl Engineer,
Inview Technology Ltd.,
Northwich, England.

Under Win32, some paths may be reported with wrong "slash"

Migrated from rt.cpan.org #82534 (status was 'open')

Requestors:

Attachments:

From [email protected] (@dakkar) on 2013-01-07 11:17:56
:

http://cpantesters.org/cpan/report/4bec28d4-6bf7-1014-8bfa-8166d1d52598 makes me suspect that, under Win32, an event path may be reported with a forward slash instead of a back-slash.

The test is comparing a path created via Path::Class (which uses File::Spec internally) with a path returned from ChangeNotify. The former is C:\DOCUME~1\Admin\LOCALS~1\Temp\1R8WMye9O3\_queue_not_subscribed, the latter is C:\DOCUME~1\Admin\LOCALS~1\Temp\1R8WMye9O3/_queue_not_subscribed

If I get access to a Windows machine, I'll write a minimal test case, but getting access may take some time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.