Skip to content

Commit

Permalink
Merge pull request #64 from zopefoundation/fix-loadBefore-deleted-data
Browse files Browse the repository at this point in the history
Fixed: FileStorage loadBefore didn't handle deleted/undone data correctly
  • Loading branch information
jimfulton committed Jun 6, 2016
2 parents b1ea673 + 5b18a71 commit b7ea4e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -29,6 +29,8 @@
- DemoStorage: add support for conflict resolution and fix history()
https://github.com/zopefoundation/ZODB/pull/58

- Fixed: FileStorage loadBefore didn't handle deleted/undone data correctly.

4.2.0 (2015-06-02)
==================

Expand Down
6 changes: 4 additions & 2 deletions src/ZODB/FileStorage/FileStorage.py
Expand Up @@ -489,11 +489,13 @@ def loadBefore(self, oid, tid):
if not pos:
return None

if h.back:
if h.plen:
return _file.read(h.plen), h.tid, end_tid
elif h.back:
data, _, _, _ = self._loadBack_impl(oid, h.back, _file=_file)
return data, h.tid, end_tid
else:
return _file.read(h.plen), h.tid, end_tid
raise POSKeyError(oid)

def store(self, oid, oldserial, data, version, transaction):
if self._is_read_only:
Expand Down
4 changes: 4 additions & 0 deletions src/ZODB/tests/TransactionalUndoStorage.py
Expand Up @@ -179,6 +179,10 @@ def checkUndoCreationBranch1(self):
info = self._storage.undoInfo()
self._undo(info[2]['id'], [oid])
self.assertRaises(KeyError, self._storage.load, oid, '')

# Loading current data via loadBefore should raise a POSKeyError too:
self.assertRaises(KeyError, self._storage.loadBefore, oid,
b'\x7f\xff\xff\xff\xff\xff\xff\xff')
self._iterate()

def checkUndoCreationBranch2(self):
Expand Down

0 comments on commit b7ea4e6

Please sign in to comment.