[Zodb-checkins] CVS: ZODB3/bsddb3Storage/bsddb3Storage - BerkeleyBase.py:1.34

Barry Warsaw barry@wooz.org
Tue, 10 Dec 2002 16:48:48 -0500


Update of /cvs-repository/ZODB3/bsddb3Storage/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv20286

Modified Files:
	BerkeleyBase.py 
Log Message:
cleanup(): Add both a method to FileStorage and a module global
function to clean up all the files that a FileStorage creates.
Sometimes it's handy to do a cleanup if you have the instance, other
times you only have the Data.fs file name.


=== ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py 1.33 => 1.34 ===
--- ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py:1.33	Fri Dec  6 18:11:29 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py	Tue Dec 10 16:48:47 2002
@@ -19,6 +19,7 @@
 import os
 import time
 import errno
+import shutil
 import threading
 from types import StringType
 
@@ -431,6 +432,10 @@
         finally:
             self._lock_release()
 
+    def cleanup(self):
+        """Remove the entire environment directory for this storage."""
+        cleanup(self._env.db_home)
+
 
 
 def env_from_string(envname, config):
@@ -472,6 +477,16 @@
         lockfile.close()
         raise
     return env, lockfile
+
+
+
+def cleanup(envdir):
+    """Remove the entire environment directory for a Berkeley storage."""
+    try:
+        shutil.rmtree(envdir)
+    except OSError, e:
+        if e.errno <> errno.ENOENT:
+            raise