[Zodb-checkins] CVS: Zope3/src/zodb/storage - file.py:1.5.2.2

Jeremy Hylton jeremy@zope.com
Thu, 23 Jan 2003 12:46:39 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv19788

Modified Files:
      Tag: new-pickle-branch
	file.py 
Log Message:
Fix computation of data record len in presence of versions.

Also:
Rename read_index() which should not be used any more.
Fix test against 4 to uses _metadata_size.


=== Zope3/src/zodb/storage/file.py 1.5.2.1 => 1.5.2.2 ===
--- Zope3/src/zodb/storage/file.py:1.5.2.1	Tue Jan 21 11:20:39 2003
+++ Zope3/src/zodb/storage/file.py	Thu Jan 23 12:46:35 2003
@@ -341,7 +341,7 @@
                 pos = tend + 8
                 continue
 
-            pos = tpos + (TRANS_HDR_LEN+ul+dl+el)
+            pos = tpos + (TRANS_HDR_LEN + ul + dl + el)
             while pos < tend:
                 # Read the data records for this transaction
                 h = self._read_data_header(pos)
@@ -350,9 +350,11 @@
 
                 if h.version:
                     vindex[h.version] = pos
+                    dlen += 16 + len(h.version)
 
                 if pos + dlen > tend or h.tloc != tpos:
-                    if recover: return tpos, None, None
+                    if recover:
+                        return tpos, None, None
                     panic("%s data record exceeds transaction record at %s",
                           self._file.name, pos)
                     
@@ -637,8 +639,7 @@
         if index is None or pos is None or oid is None or vindex is None:
             return None
 
-        # if pos == 4, then the storage is empty.
-        if pos > 4:
+        if pos > self._metadata_size: # otherwise storage is empty
             # Get the last transaction
             self._file.seek(pos - 8)
             tl = u64(self._file.read(8))
@@ -2045,7 +2046,7 @@
 
 
 
-def read_index(file, name, index, vindex, tindex, stop='\377'*8,
+def Xread_index(file, name, index, vindex, tindex, stop='\377'*8,
                ltid=z64, start=4L, maxoid=z64, recover=0, read_only=0):
     """Scan the entire file storage and recreate the index.