From: minima Date: Fri, 25 Oct 2002 12:47:06 +0000 (+0000) Subject: remove the dupefile automatically if it can't be opened X-Git-Tag: PRE-1-52~122 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=commitdiff_plain;h=070310c653f25c63a719396a32c216b5ce8b9dee remove the dupefile automatically if it can't be opened --- diff --git a/Changes b/Changes index 666930a5..cae5b66a 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ +25Oct02======================================================================= +1. remove the dupefile automatically if it becomes corrupted 21Oct02======================================================================= 1. Fix msg aging. 2. make the default pinginterval and obscount variable (set/var diff --git a/perl/DXDupe.pm b/perl/DXDupe.pm index 4cc2be6f..fb1210a2 100644 --- a/perl/DXDupe.pm +++ b/perl/DXDupe.pm @@ -28,6 +28,13 @@ $main::branch += $BRANCH; sub init { $dbm = tie (%d, 'DB_File', $fn) or confess "can't open dupe 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 diff --git a/perl/DXUser.pm b/perl/DXUser.pm index 2c562ac7..cf847bc8 100644 --- a/perl/DXUser.pm +++ b/perl/DXUser.pm @@ -122,9 +122,9 @@ sub init confess "need a filename in User" if !$fn; $fn .= ".v2"; if ($mode) { - $dbm = tie (%u, 'DB_File', $fn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!)"; + $dbm = tie (%u, 'DB_File', $fn, O_CREAT|O_RDWR, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]"; } else { - $dbm = tie (%u, 'DB_File', $fn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!)"; + $dbm = tie (%u, 'DB_File', $fn, O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn ($!) [rebuild it from user_asc?]"; } $filename = $fn;