1212import struct
1313import re
1414import os
15+ import os .path
1516import base64
1617import httplib
1718import sys
@@ -115,19 +116,20 @@ def __init__(self, settings, blkindex, blkmap):
115116 self .setFileTime = True
116117 if settings ['split_timestamp' ] != 0 :
117118 self .timestampSplit = True
118- # Extents and cache for out-of-order blocks
119+ # Extents and cache for out-of-order blocks
119120 self .blockExtents = {}
120121 self .outOfOrderData = {}
121122 self .outOfOrderSize = 0 # running total size for items in outOfOrderData
122123
123124 def writeBlock (self , inhdr , blk_hdr , rawblock ):
124- if not self .fileOutput and ((self .outsz + self .inLen ) > self .maxOutSz ):
125+ blockSizeOnDisk = len (inhdr ) + len (blk_hdr ) + len (rawblock )
126+ if not self .fileOutput and ((self .outsz + blockSizeOnDisk ) > self .maxOutSz ):
125127 self .outF .close ()
126128 if self .setFileTime :
127129 os .utime (outFname , (int (time .time ()), highTS ))
128130 self .outF = None
129131 self .outFname = None
130- self .outFn = outFn + 1
132+ self .outFn = self . outFn + 1
131133 self .outsz = 0
132134
133135 (blkDate , blkTS ) = get_blk_dt (blk_hdr )
@@ -147,7 +149,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
147149 if self .fileOutput :
148150 outFname = self .settings ['output_file' ]
149151 else :
150- outFname = "%s/blk%05d.dat" % (self .settings ['output' ], outFn )
152+ outFname = os . path . join (self .settings ['output' ], "blk%05d.dat" % self . outFn )
151153 print ("Output file " + outFname )
152154 self .outF = open (outFname , "wb" )
153155
@@ -165,7 +167,7 @@ def writeBlock(self, inhdr, blk_hdr, rawblock):
165167 (self .blkCountIn , self .blkCountOut , len (self .blkindex ), 100.0 * self .blkCountOut / len (self .blkindex )))
166168
167169 def inFileName (self , fn ):
168- return "%s/blk%05d.dat" % (self .settings ['input' ], fn )
170+ return os . path . join (self .settings ['input' ], "blk%05d.dat" % fn )
169171
170172 def fetchBlock (self , extent ):
171173 '''Fetch block contents from disk given extents'''
0 commit comments