source: subversion/sites/other/trapi/monitor.pl @ 31161

Last change on this file since 31161 was 20398, checked in by deelkar, 10 years ago

add so called "ugly hack" to support replicate diffs. By Milenko

File size: 772 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use constant VERBOSE => 0;
7
8use File::Monitor;
9use trapi;
10
11$| = 1;
12
13opendir(DIR, CHANGEDIR);
14my @filelist=readdir(DIR);
15closedir(DIR);
16@filelist=sort(@filelist);
17
18for my $existingfile ( @filelist ) {
19        if ($existingfile =~ /\d+\-(\d+)-(\d+)\.osc\.gz$/) {
20          print CHANGEDIR.$existingfile."\n";
21        }
22}
23
24my $monitor = File::Monitor->new();
25
26$monitor->watch( {
27        name        => CHANGEDIR,
28        callback    => \&somethingchanged,
29        files => 1
30        }
31);
32
33$monitor->scan();
34
35while ()
36{
37        $monitor->scan();   
38        sleep 10;
39}
40
41sub somethingchanged
42{
43        my ($name, $event, $change) = @_;
44
45        my @adds = $change->files_created;
46        @adds=sort(@adds);
47
48        for my $files ( @adds ){
49          print $files."\n" if ($files =~ /\d+\-(\d+)-(\d+)\.osc\.gz$/);
50        }
51        return 1;
52}
Note: See TracBrowser for help on using the repository browser.