[Zodb-checkins] SVN: ZODB/trunk/ Fixed bug 129921

Christian Theune ct at gocept.com
Wed Aug 29 02:23:56 EDT 2007


Log message for revision 79336:
  Fixed bug 129921
  

Changed:
  U   ZODB/trunk/NEWS.txt
  U   ZODB/trunk/src/ZODB/blob.py
  U   ZODB/trunk/src/ZODB/tests/blob_transaction.txt

-=-
Modified: ZODB/trunk/NEWS.txt
===================================================================
--- ZODB/trunk/NEWS.txt	2007-08-28 23:42:34 UTC (rev 79335)
+++ ZODB/trunk/NEWS.txt	2007-08-29 06:23:54 UTC (rev 79336)
@@ -31,6 +31,9 @@
 - (3.9.0a1) Fixed bug #126007: tpc_abort had untested code path that was
   broken.
 
+- (3.9.0a1) Fixed bug #129921: getSize() function in BlobStorage could not
+  deal with garbage files
+
 BTrees
 ------
 

Modified: ZODB/trunk/src/ZODB/blob.py
===================================================================
--- ZODB/trunk/src/ZODB/blob.py	2007-08-28 23:42:34 UTC (rev 79335)
+++ ZODB/trunk/src/ZODB/blob.py	2007-08-29 06:23:54 UTC (rev 79336)
@@ -544,11 +544,13 @@
     def getSize(self):
         """Return the size of the database in bytes."""
         orig_size = getProxiedObject(self).getSize()
-
         blob_size = 0
         base_dir = self.fshelper.base_dir
         for oid in os.listdir(base_dir):
-            for serial in os.listdir(os.path.join(base_dir, oid)):
+            sub_dir = os.path.join(base_dir, oid)
+            if not os.path.isdir(sub_dir):
+                continue
+            for serial in os.listdir(sub_dir):
                 if not serial.endswith(BLOB_SUFFIX):
                     continue
                 file_path = os.path.join(base_dir, oid, serial)

Modified: ZODB/trunk/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/trunk/src/ZODB/tests/blob_transaction.txt	2007-08-28 23:42:34 UTC (rev 79335)
+++ ZODB/trunk/src/ZODB/tests/blob_transaction.txt	2007-08-29 06:23:54 UTC (rev 79336)
@@ -321,7 +321,7 @@
     ...         pass
     >>> base_storage = DummyBaseStorage()
     >>> blob_dir2 = mkdtemp()
-    >>> blob_storage = BlobStorage(blob_dir2, base_storage)
+    >>> blob_storage2 = BlobStorage(blob_dir2, base_storage)
     >>> committed_blob_dir = os.path.join(blob_dir2, '0')
     >>> committed_blob_file = os.path.join(committed_blob_dir, '0.blob')
     >>> os.mkdir(committed_blob_dir)
@@ -333,14 +333,29 @@
 will: remove the committed file for Blob 0 and ignore the fact that Blob 1 is
 set to dirty but doesn't actually have an existing file:
 
-    >>> blob_storage.dirty_oids = [(0, 0), (1, 0)]
-    >>> blob_storage.tpc_abort()
+    >>> blob_storage2.dirty_oids = [(0, 0), (1, 0)]
+    >>> blob_storage2.tpc_abort()
     >>> os.path.exists(committed_blob_file)
     False
 
 
 Note: This is a counter measure against regression of bug #126007.
 
+getSize with garbage in the directory structure
+-----------------------------------------------
+
+`getSize` iterates over the existing blob files in the blob directory and adds
+up their size. The blob directory sometimes contains temporary files that the
+getSize function needs to ignore:
+
+    >>> garbage_file = os.path.join(blob_dir, 'garbage')
+    >>> open(garbage_file, 'w').write('garbage')
+    >>> int(blob_storage.getSize())
+    881
+
+
+Note: This is a counter measer against regression of bug #12991.
+
 Teardown
 --------
 



More information about the Zodb-checkins mailing list