From c057ef0ea7bd80874415e59ec62e544dd8ed5633 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 28 Jul 2009 22:34:13 -0700 Subject: Fixed some off-by-one errors in write when extending the blocks with nulls diff --git a/fusearchive.py b/fusearchive.py index 15d4d60..9c13d68 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -551,6 +551,8 @@ class FuseArchive(Fuse): def _load_chunk( self, index ): # If the current chunk is the same as the chunk we're loading # just return + logging.debug( "_load_chunk: " + str( index ) ) + if index == self.chunk_index: logging.debug( "Load chunk is same as current chunk, all done" ) return @@ -671,20 +673,21 @@ class FuseArchive(Fuse): rest = offset % self.chunk_size logging.debug( "This chunk falls on index: " + str( index ) + " rest: " + str( rest ) ) + logging.debug( "We have " + str( len( self.chunks ) ) + " chunks" ) # If index is higher than the number of blocks we current have it's a seek hole, so we need to extend our blocks out # We know these need to essentially be zeroed up to this size since - while index > len( self.chunks ): + if len( self.chunks ) - 1 < index: logging.debug( "Not enough chunks " + str( len( self.chunks ) ) + ", need " + str( index ) + ", extending" ) - this_index = -1 + this_index = 0 while this_index < index: - this_index += 1 self._load_chunk( this_index ) fill_null = self.chunk_size - len(self.chunk) logging.debug( "Filling this chunk with null, bytes: " + str( fill_null ) ) self.chunk += "\0" * fill_null self.chunk_modified = True + this_index += 1 self._load_chunk( index ) -- cgit v0.10.2