$default = 48*24*60*60;
$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,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
+localdata_mv("dupefile");
+$fn = localdata("dupefile");
sub init
{
+ unlink $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;
- }
+ confess "cannot open $fn $!" unless $dbm;
}
sub finish
undef $dbm;
untie %d;
undef %d;
+ unlink $fn;
}
sub check
{
# once an hour
if ($main::systime - $lasttime >= 3600) {
+ my @del;
while (($k, $v) = each %d) {
- delete $d{$k} if $main::systime >= $v;
+ push @del, $k if $main::systime >= $v;
}
+ delete $d{$_} for @del;
$lasttime = $main::systime;
}
}