[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.98

Jeremy Hylton jeremy@zope.com
Wed, 28 Aug 2002 14:19:14 -0400


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv13716

Modified Files:
	FileStorage.py 
Log Message:
If we are aborting, the serialno in the new data record should be the
same as the serialno in the last non-version data record.

XXX This might be the only time that the serialno of a data record
does not match the transaction id.


=== ZODB3/ZODB/FileStorage.py 1.97 => 1.98 ===
--- ZODB3/ZODB/FileStorage.py:1.97	Wed Aug 28 12:41:32 2002
+++ ZODB3/ZODB/FileStorage.py	Wed Aug 28 14:19:13 2002
@@ -483,7 +483,8 @@
         current_oids = {}
         t = None
         tstatus = ' '
-        newserial = self._serial
+        if abort is None:
+            newserial = self._serial
 
         while srcpos:
             self._file.seek(srcpos)
@@ -491,6 +492,16 @@
             # h -> oid, serial, prev(oid), tloc, vlen, plen, pnv, pv
             oid = h[:8]
             pnv = h[-16:-8]
+            if abort:
+                # If we are aborting, the serialno in the new data
+                # record should be the same as the serialno in the last
+                # non-version data record.
+                # XXX This might be the only time that the serialno
+                # of a data record does not match the transaction id.
+                self._file.seek(U64(pnv))
+                h_pnv = self._file.read(DATA_VERSION_HDR_LEN)
+                newserial = h_pnv[8:16]
+            
             if self._index.get(oid) == srcpos:
                 # This is a current record!
                 self._tindex[oid] = here
@@ -577,26 +588,27 @@
 
     def _load(self, oid, version, _index, file):
         try:
-            pos=_index[oid]
+            pos = _index[oid]
         except KeyError:
             raise POSKeyError(oid)
         file.seek(pos)
-        read=file.read
-        h=read(DATA_HDR_LEN)
-        doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h)
-        if doid != oid: raise CorruptedDataError, h
+        read = file.read
+        h = read(DATA_HDR_LEN)
+        doid, serial, prev, tloc, vlen, plen = unpack(">8s8s8s8sH8s", h)
+        if doid != oid:
+            raise CorruptedDataError, h
         if vlen:
-            pnv=read(8) # Read location of non-version data
+            pnv = read(8) # Read location of non-version data
             if (not version or len(version) != vlen or
                 (read(8) # skip past version link
-                 and version != read(vlen))
-                ):
+                 and version != read(vlen))):
                 return _loadBack(file, oid, pnv)
 
         # If we get here, then either this was not a version record,
         # or we've already read past the version data!
-        if plen != z64: return read(U64(plen)), serial
-        pnv=read(8)
+        if plen != z64:
+            return read(U64(plen)), serial
+        pnv = read(8)
         # We use the current serial, since that is the one that
         # will get checked when we store.
         return _loadBack(file, oid, pnv)[0], serial