Commit 2db52418 authored by Christian Theune's avatar Christian Theune

Fixed bug 129921

parent 4fb6aa13
...@@ -31,6 +31,9 @@ Blobs ...@@ -31,6 +31,9 @@ Blobs
- (3.9.0a1) Fixed bug #126007: tpc_abort had untested code path that was - (3.9.0a1) Fixed bug #126007: tpc_abort had untested code path that was
broken. broken.
- (3.9.0a1) Fixed bug #129921: getSize() function in BlobStorage could not
deal with garbage files
BTrees BTrees
------ ------
......
...@@ -544,11 +544,13 @@ class BlobStorage(SpecificationDecoratorBase): ...@@ -544,11 +544,13 @@ class BlobStorage(SpecificationDecoratorBase):
def getSize(self): def getSize(self):
"""Return the size of the database in bytes.""" """Return the size of the database in bytes."""
orig_size = getProxiedObject(self).getSize() orig_size = getProxiedObject(self).getSize()
blob_size = 0 blob_size = 0
base_dir = self.fshelper.base_dir base_dir = self.fshelper.base_dir
for oid in os.listdir(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): if not serial.endswith(BLOB_SUFFIX):
continue continue
file_path = os.path.join(base_dir, oid, serial) file_path = os.path.join(base_dir, oid, serial)
......
...@@ -321,7 +321,7 @@ clean up dirty files: ...@@ -321,7 +321,7 @@ clean up dirty files:
... pass ... pass
>>> base_storage = DummyBaseStorage() >>> base_storage = DummyBaseStorage()
>>> blob_dir2 = mkdtemp() >>> 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_dir = os.path.join(blob_dir2, '0')
>>> committed_blob_file = os.path.join(committed_blob_dir, '0.blob') >>> committed_blob_file = os.path.join(committed_blob_dir, '0.blob')
>>> os.mkdir(committed_blob_dir) >>> os.mkdir(committed_blob_dir)
...@@ -333,14 +333,29 @@ Now, telling the storage that Blob 0 and Blob 1 (both with serial 0) are dirty ...@@ -333,14 +333,29 @@ Now, telling the storage that Blob 0 and Blob 1 (both with serial 0) are dirty
will: remove the committed file for Blob 0 and ignore the fact that Blob 1 is 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: set to dirty but doesn't actually have an existing file:
>>> blob_storage.dirty_oids = [(0, 0), (1, 0)] >>> blob_storage2.dirty_oids = [(0, 0), (1, 0)]
>>> blob_storage.tpc_abort() >>> blob_storage2.tpc_abort()
>>> os.path.exists(committed_blob_file) >>> os.path.exists(committed_blob_file)
False False
Note: This is a counter measure against regression of bug #126007. 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 Teardown
-------- --------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment