[Zodb-checkins] SVN: ZODB/branches/3.8/ Fixed bug #129921.

Christian Theune ct at gocept.com
Wed Aug 29 02:33:03 EDT 2007


Log message for revision 79337:
  Fixed bug #129921.
  

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

-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt	2007-08-29 06:23:54 UTC (rev 79336)
+++ ZODB/branches/3.8/NEWS.txt	2007-08-29 06:33:02 UTC (rev 79337)
@@ -82,6 +82,9 @@
 - (3.8b3) Fixed bug #126007: tpc_abort had untested code path that was
   broken.
 
+- (3.8b3) Fixed bug #129921: getSize() function in BlobStorage could not
+  deal with garbage files
+
 - (3.8b1) Updated the Blob implementation in a number of ways.  Some
   of these are backward incompatible with 3.8a1:
 

Modified: ZODB/branches/3.8/src/ZODB/blob.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/blob.py	2007-08-29 06:23:54 UTC (rev 79336)
+++ ZODB/branches/3.8/src/ZODB/blob.py	2007-08-29 06:33:02 UTC (rev 79337)
@@ -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/branches/3.8/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt	2007-08-29 06:23:54 UTC (rev 79336)
+++ ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt	2007-08-29 06:33:02 UTC (rev 79337)
@@ -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