[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Better error recovery on unsupported or corrupted datab...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv20589/lib/mixminion

Modified Files:
	Filestore.py 
Log Message:
Better error recovery on unsupported or corrupted databases

Index: Filestore.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Filestore.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Filestore.py	28 Sep 2003 04:12:29 -0000	1.12
+++ Filestore.py	7 Nov 2003 06:59:35 -0000	1.13
@@ -22,6 +22,7 @@
 import stat
 import threading
 import time
+import whichdb
 
 from mixminion.Common import MixError, MixFatalError, secureDelete, LOG, \
      createPrivateDir, readFile, tryUnlink
@@ -570,7 +571,15 @@
             tryUnlink(filename)
 
         LOG.debug("Opening %s database at %s", purpose, filename)
-        self.log = anydbm.open(filename, 'c')
+        try:
+            self.log = anydbm.open(filename, 'c')
+        except anydbm.error, e:
+            raise MixFatalError("Can't open %s database: %s"%(purpose,e))
+        except ImportError:
+            dbtype = whichdb.whichdb(filename)
+            raise MixFatalError("Unsupported type for %s database: %s"
+                                %(purpose, dbtype))
+        
         if hasattr(self.log, 'sync'):
             self._syncLog = self.log.sync
         elif hasattr(self.log, '_commit'):