Skip to content

Commit

Permalink
Merge pull request #283 from zopefoundation/issue282
Browse files Browse the repository at this point in the history
Make TmpStore implement its own getSize
  • Loading branch information
jamadden committed Sep 27, 2019
2 parents 2f8cc67 + 0d089b4 commit 8388009
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -24,6 +24,11 @@
holds bytes as they are stored (i.e. no deserialization happens).
See `issue 207 <https://github.com/zopefoundation/ZODB/pull/207>`_.

- Make a connection's savepoint storage implement its own
(approximate) ``getSize`` method instead of relying on the original
storage. Previously, this produced confusing DEBUG logging. See
`issue 282 <https://github.com/zopefoundation/ZODB/issues/282>`_.

5.5.1 (2018-10-25)
==================

Expand Down
10 changes: 6 additions & 4 deletions src/ZODB/Connection.py
Expand Up @@ -1135,21 +1135,23 @@ class TmpStore(object):
def __init__(self, storage):
self._storage = storage
for method in (
'getName', 'new_oid', 'getSize', 'sortKey',
'getName', 'new_oid', 'sortKey',
'isReadOnly'
):
setattr(self, method, getattr(storage, method))

self._file = tempfile.TemporaryFile(prefix='TmpStore')
# position: current file position
# _tpos: file position at last commit point
# position: current file position. If objects are only stored
# once, this is approximately the byte size of object data stored.
self.position = 0
# index: map oid to pos of last committed version
self.index = {}
self.creating = {}

self._blob_dir = None

def getSize(self):
return self.position

def __len__(self):
return len(self.index)

Expand Down

0 comments on commit 8388009

Please sign in to comment.