Skip to content

Commit

Permalink
Fixed: FileStorage loadBefore didn't handle deleted/undone data corre…
Browse files Browse the repository at this point in the history
…ctly.
  • Loading branch information
Jim Fulton committed Jun 5, 2016
1 parent 6fe36b9 commit 5b18a71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 5b18a71

Please sign in to comment.