remove the dupefile automatically if it can't be opened
authorminima <minima>
Fri, 25 Oct 2002 12:47:06 +0000 (12:47 +0000)
committerminima <minima>
Fri, 25 Oct 2002 12:47:06 +0000 (12:47 +0000)
Changes
perl/DXDupe.pm
perl/DXUser.pm

diff --git a/Changes b/Changes
index 666930a5e713afd15dc50f7418d262346574a8ec..cae5b66a403f976e6f2ef54be909f7ba8f245c43 100644 (file)
--- 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 
index 4cc2be6ff936fccb7fb6693b642daade97b7ca19..fb1210a2a15b7186c11980712b52ba6120d80a1d 100644 (file)
@@ -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
index 2c562ac70ed538d12373150fd08b2e15944a1b4f..cf847bc897778748295e61aa41d15962a8ef83a3 100644 (file)
@@ -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;