X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXDupe.pm;h=1a0eb14c9de608afca15c330b73155c9704a7411;hb=9cb17cdc59baad6fd8d175ec9a644575cdc8c5d5;hp=5a01bee99a6acdfa1e6e39c204e623a2d1c46ba4;hpb=2b58ccdf81685a1167a43c38705a0d84b9d8d661;p=spider.git diff --git a/perl/DXDupe.pm b/perl/DXDupe.pm index 5a01bee9..1a0eb14c 100644 --- a/perl/DXDupe.pm +++ b/perl/DXDupe.pm @@ -20,14 +20,19 @@ $lasttime = 0; $fn = "$main::data/dupefile"; use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0; -$main::build += $VERSION; -$main::branch += $BRANCH; + +main::mkver($VERSION = q$Revision$); sub init { - $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe file: $fn ($!)"; + $dbm = tie (%d, 'DB_File', $fn); + unless ($dbm) { + eval { untie %d }; + dbg("Dupefile $fn corrupted, removing..."); + unlink $fn; + $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe file: $fn ($!)"; + confess "cannot open $fn $!" unless $dbm; + } } sub finish @@ -39,13 +44,24 @@ sub finish sub check { - my ($s, $t) = @_; - return 1 if exists $d{$s}; - $t = $main::systime + $default unless $t; - $d{$s} = $t; + my $s = shift; + return 1 if find($s); + add($s, shift); return 0; } +sub find +{ + return $d{$_[0]}; +} + +sub add +{ + my $s = shift; + my $t = shift || $main::systime + $default; + $d{$s} = $t; +} + sub del { my $s = shift;