Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
thank you very much for your suggestion.
yours and Browser_Uk were the same ideas actually
so I have documented myself a bit and written a daemon
which is sitting and monitoring for changes in files.
the following is what I cam up with(teste and works excellent):
#!/usr/bin/perl #this lightweight daemon will run in the background and #for each new file that is modified and closed it will re-hash it and +update #its entry in the database use strict; use warnings; # #bugs encountered: # #1)does not update as expected in database the new sha1 #2)$mtime seems to be very VERY different from DateTime->now which is +weird #3)bug found in SHA1db find_or_update not finding correctly if there a +re any files in the db with #that name # # use Linux::Inotify2; use Data::Dumper; use DateTime; use SHA1db; use YAML qw/LoadFile/; $|=1; SHA1db->connect(); my $inotify = new Linux::Inotify2(); my $config_path = 'config.yml'; my $config = LoadFile($config_path); for (map {$_->{path}} @{ $config->{directories} }) { print "tracking $_\n"; $inotify->watch($_, IN_ALL_EVENTS); } while () { my @events = $inotify->read; unless (@events > 0) { print "read error: $!"; last ; }; for(@events) { next unless($_->mask & IN_CLOSE_WRITE); my $mtime =( lstat($_->fullname) )[9]; next unless $mtime; printf "updating checksum_db for file %s modified now: %s\n",$ +_->fullname,DateTime->from_epoch(epoch=>$mtime); #we should add a check to see if this file passes the regex #filter & link filter & dir filter & size filter unless(SHA1db::find_or_update($_->fullname,$mtime)) { printf "not found in db,adding...\n"; SHA1db::add_to_db(SHA1db::file2sha1($_->fullname),$mtime,- +s _ ,$_->fullname); #add it to db }; }; }; print "daemon stopped";

In reply to Re^4: the sands of time(in search of an optimisation) by spx2
in thread the sands of time(in search of an optimisation) by spx2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-19 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found