X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=onis;h=c34fc74be1c0218cac292968b64aafb6e1e8e609;hb=af6b056de33ad49db7d1371ff6d8f8cadd0b5eab;hp=650d8a5ca429cdbd9e3203cf036cb38d536a8827;hpb=6761942ff0fa8b17ca367bd2b2bfee11fdf80c6b;p=onis.git diff --git a/onis b/onis index 650d8a5..c34fc74 100755 --- a/onis +++ b/onis @@ -37,14 +37,21 @@ use Onis::Config qw/get_config parse_argv read_config/; use File::Basename qw/dirname/; use Fcntl qw/:flock/; -use vars qw/$VERSION/; +use vars qw/$VERSION $REVISION/; -$VERSION = '0.7.2'; +$VERSION = ''; +$REVISION = '$LastChangedRevision$'; -our $FILEINFO; +if (!$VERSION) +{ + $VERSION = $REVISION; + $VERSION =~ s/^\D*(\d+).*/r$1/; +} + +our $FileInfo; our $PURGE_LOGS = 0; -print STDERR $/, __FILE__, ': $Id: onis,v 1.18 2005/01/21 18:59:59 octo Exp $' if ($::DEBUG); +print STDERR $/, __FILE__, ': $Id$' if ($::DEBUG); parse_argv (@ARGV); read_config (get_config ('config') ? get_config ('config') : 'config'); @@ -119,11 +126,11 @@ if (get_config ('logtype')) require "Onis/Parser/$logtype.pm"; require Onis::Parser::Persistent; require Onis::Data::Persistent; -import Onis::Parser qw/parse last_date/; -import Onis::Parser::Persistent qw#newfile#; -import Onis::Data::Persistent qw#init#; +import Onis::Parser (qw(parse last_date)); +import Onis::Parser::Persistent (qw(newfile)); +import Onis::Data::Persistent (); -$FILEINFO = init ('$FILEINFO', 'hash'); +$FileInfo = Onis::Data::Persistent->new ('FileInfo', 'inode', qw(mtime)); if (get_config ('purge_logs')) { @@ -160,15 +167,18 @@ for (get_config ('input')) } else { + my ($old_mtime) = $FileInfo->get ($inode); + print STDERR $/, __FILE__, ": ``$file'': " if ($::DEBUG & 0x200); - if (defined ($FILEINFO->{$inode}{'mtime'})) + + if (defined ($old_mtime)) { - if ($FILEINFO->{$inode}{'mtime'} == $mtime) + if ($old_mtime == $mtime) { print STDERR "File did not change. Skipping." if ($::DEBUG & 0x200); next; } - elsif ($FILEINFO->{$inode}{'mtime'} < $mtime) + elsif ($old_mtime < $mtime) { print STDERR "File changed. Reading it again." if ($::DEBUG & 0x200); } @@ -181,7 +191,7 @@ for (get_config ('input')) { print STDERR "File appears to be new. Reading it." if ($::DEBUG & 0x200); } - $FILEINFO->{$inode}{'mtime'} = $mtime; + $FileInfo->put ($inode, $mtime); } # truncate @@ -221,7 +231,7 @@ for (get_config ('input')) } } - newfile ($FILEINFO->{$inode}); + newfile ($FileInfo->{$inode}); while (<$logfile>) { s/\n|\r//g; @@ -272,7 +282,7 @@ for (get_config ('input')) { print STDERR $/, __FILE__, ": Unable to delete empty file ``$file'': $!"; } - delete ($FILEINFO->{$inode}); + delete ($FileInfo->{$inode}); } else {