aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-29 05:34:13 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-29 05:34:13 (GMT)
commitc057ef0ea7bd80874415e59ec62e544dd8ed5633 (patch)
tree0e3434d83091bd01516b03003b045346584c7650
parentbb7342253d6e9b3a2b0003565b3fd2cfb50d15f2 (diff)
downloadfusearchive-c057ef0ea7bd80874415e59ec62e544dd8ed5633.zip
fusearchive-c057ef0ea7bd80874415e59ec62e544dd8ed5633.tar.gz
fusearchive-c057ef0ea7bd80874415e59ec62e544dd8ed5633.tar.bz2
Fixed some off-by-one errors in write when extending the blocks with nulls
-rwxr-xr-xfusearchive.py9
1 files changed, 6 insertions, 3 deletions
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 )