Commit b94b218f authored by Jeremy Hylton's avatar Jeremy Hylton

Small change to pack to make it more robust.

If the packpos returned by the read_index() call is 4, return immediately.
In this case, the very first transaction, which contains the root object,
is after the pack time.  This is a degenerate case, but it seems clearest
to do nothing.

This change eliminates an unexpected traceback in pack() that occurred
frequently, but not every time, when testing on Windows.  When
read_index() returned 4, a seek() call in _redundant_pack() would fail
with a bad argument.

Add an assertion to _redundant_pack() because it should never be called
with bogus arguments as a result of the other change.
parent 0b70a63b
......@@ -186,7 +186,7 @@
# may have a back pointer to a version record or to a non-version
# record.
#
__version__='$Revision: 1.74 $'[11:-2]
__version__='$Revision: 1.75 $'[11:-2]
import struct, time, os, bpthread, string, base64, sys
from struct import pack, unpack
......@@ -1231,6 +1231,7 @@ class FileStorage(BaseStorage.BaseStorage,
finally: self._lock_release()
def _redundant_pack(self, file, pos):
assert pos > 8, pos
file.seek(pos-8)
p=U64(file.read(8))
file.seek(pos-p+8)
......@@ -1280,6 +1281,8 @@ class FileStorage(BaseStorage.BaseStorage,
read_only=1,
)
if packpos == 4:
return
if self._redundant_pack(file, packpos):
raise FileStorageError, (
'The database has already been packed to a later time\n'
......
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