[Checkins] SVN: zc.FileStorage/trunk/src/zc/FileStorage/__init__.py Added a weird onerror handler for shutil.rmtree to deal with off

Jim Fulton jim at zope.com
Wed Dec 10 16:55:34 EST 2008


Log message for revision 93857:
  Added a weird onerror handler for shutil.rmtree to deal with off
  errors in which removing files suceeds but returns a non-found sort of
  error.
  

Changed:
  U   zc.FileStorage/trunk/src/zc/FileStorage/__init__.py

-=-
Modified: zc.FileStorage/trunk/src/zc/FileStorage/__init__.py
===================================================================
--- zc.FileStorage/trunk/src/zc/FileStorage/__init__.py	2008-12-10 20:53:06 UTC (rev 93856)
+++ zc.FileStorage/trunk/src/zc/FileStorage/__init__.py	2008-12-10 21:55:34 UTC (rev 93857)
@@ -641,8 +641,12 @@
         ioid2 = int(ioid2)
         if references_ioid1[0].pop(ioid2, None) is None:
             references_ioid1[1].pop(ioid2, None)
-        
 
+def _rmtree_onerror(func, path, exc_info):
+    if os.path.exists(path):
+        raise exc_info[0], exc_info[1], exc_info[2]
+    logging.info('burp removing %s', path)
+
 class FileReferences:
 
     cache_size = 999
@@ -653,7 +657,7 @@
                                              lambda k, v: v.save())
         path += '.refs'
         if os.path.isdir(path):
-            shutil.rmtree(path)
+            shutil.rmtree(path, onerror=_rmtree_onerror)
         os.mkdir(path)
         self._tmp = path
 
@@ -662,7 +666,7 @@
         for k in cache:
             cache[k].dirty = False
         self._cache.clear()
-        shutil.rmtree(self._tmp)
+        shutil.rmtree(self._tmp, onerror=_rmtree_onerror)
 
     def _load(self, oid):
         base, index = divmod(long(oid), self.entry_size)



More information about the Checkins mailing list