Commit 75523243 authored by Jeremy Hylton's avatar Jeremy Hylton

A little cleanup and an added comment.

parent afcccf13
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.114 $'[11:-2] __version__='$Revision: 1.115 $'[11:-2]
import base64 import base64
from cPickle import Pickler, Unpickler, loads from cPickle import Pickler, Unpickler, loads
...@@ -286,6 +286,10 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -286,6 +286,10 @@ class FileStorage(BaseStorage.BaseStorage,
) )
self._ltid = tid self._ltid = tid
# self._pos should always point just past the last
# transaction. During 2PC, data is written after _pos.
# invariant is restored at tpc_abort() or tpc_finish().
self._ts = tid = TimeStamp(tid) self._ts = tid = TimeStamp(tid)
t = time.time() t = time.time()
t = apply(TimeStamp, (time.gmtime(t)[:5] + (t % 60,))) t = apply(TimeStamp, (time.gmtime(t)[:5] + (t % 60,)))
...@@ -402,15 +406,12 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -402,15 +406,12 @@ class FileStorage(BaseStorage.BaseStorage,
return ltid return ltid
def _restore_index(self): def _restore_index(self):
"""Load the database index from a file to support quick startup """Load database index to support quick startup."""
""" try:
file_name=self.__name__ f = open("%s.index" % self.__name__, 'rb')
index_name=file_name+'.index' except:
return None
try: f=open(index_name,'rb') p = Unpickler(f)
except: return None
p=Unpickler(f)
try: try:
info=p.load() info=p.load()
...@@ -419,16 +420,17 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -419,16 +420,17 @@ class FileStorage(BaseStorage.BaseStorage,
warn("Failed to load database index: %s: %s" % warn("Failed to load database index: %s: %s" %
(exc, err)) (exc, err))
return None return None
index=info.get('index') index = info.get('index')
pos=info.get('pos') pos = info.get('pos')
oid=info.get('oid') oid = info.get('oid')
vindex=info.get('vindex') vindex = info.get('vindex')
if index is None or pos is None or oid is None or vindex is None: if index is None or pos is None or oid is None or vindex is None:
return None return None
pos = long(pos) pos = long(pos)
tid=self._sane(index, pos) tid = self._sane(index, pos)
if not tid: return None if not tid:
return None
return index, vindex, pos, oid, tid return index, vindex, pos, oid, tid
......
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