aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfusearchive.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 61dc821..15d4d60 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -619,7 +619,9 @@ class FuseArchive(Fuse):
def read(self, length, offset):
logging.debug( "Reading from " + self.orig_path + " offset: " + str( offset )
- + " length: " + str( length ) )
+ + ' (0x%x) ' % offset
+ + " length: " + str( length )
+ + ' (0x%x)' % length )
data_read = 0
data = ''
@@ -661,7 +663,9 @@ class FuseArchive(Fuse):
return len( buf )
logging.debug( "Writing to " + self.orig_path + " offset: " + str( offset ) +
- ' (0x%x)' % offset )
+ ' (0x%x) ' % offset
+ + ' length: ' + str( len( buf ) )
+ + ' (0x%x)' % len( buf ) )
index = int( offset / self.chunk_size )
rest = offset % self.chunk_size
@@ -769,6 +773,8 @@ class FuseArchive(Fuse):
# And flush any cached chunks
self._flush_chunks()
+ save_size = self.size
+
# Figure out our size based on the number of chunks + the
# len of the final chunk
numchunks = len( self.chunks )
@@ -782,7 +788,12 @@ class FuseArchive(Fuse):
logging.debug( "No chunks, setting size to zero" )
self.size = 0
- logging.debug( "Size calculated is: " + str( self.size ) )
+ # If this assert fails then write/ftruncate failed to set
+ # things up right somewhere
+ assert save_size == self.size, "Calculated size " + str( self.size ) \
+ + " doesn't match internal size " + str( save_size ) \
+ + "\nProbably a bug in write or ftruncate!"
+ logging.debug( "Size calculated is: " + str( self.size ) + ' (0x%x)' % self.size )
FuseArchiveSerializer.dumpfh( self.file, {
'size': self.size,
@@ -834,7 +845,7 @@ class FuseArchive(Fuse):
curr_chunks = len( self.chunks )
need_chunks = ( length / self.chunk_size )
extra_bytes = length % self.chunk_size
- logging.debug( "Ftruncate - " + str(length) )
+ logging.debug( "Ftruncate - " + str(length) + ' (0x%x) ' % length )
logging.debug( " - curr_chunks: " + str( curr_chunks ) )
logging.debug( " - need_chunks: " + str( need_chunks ) )
logging.debug( " - extra_bytes: " + str( extra_bytes ) )
@@ -845,9 +856,10 @@ class FuseArchive(Fuse):
self._load_chunk( 0 )
- if need_chunks == 0:
+ if length == 0:
logging.debug( "Creating 0 chunk file" )
self.chunks = []
+ self.chunk = ''
elif self.size < length:
logging.debug( "Need to pad out file, writing/seeking to " + str( length ) )
@@ -874,12 +886,14 @@ class FuseArchive(Fuse):
if len( self.chunk ) > extra_bytes:
logging.debug( "Truncating final chunk to " + str( extra_bytes ) )
self.chunk = self.chunk[ :extra_bytes ]
- self.chunk_dirty = True
+ logging.debug( "Chunk is now: " + str( len( self.chunk) ) + " bytes" )
+ self.chunk_modified = True
self.modified = True
self.size = length
self._load_chunk( 0 )
+ logging.debug( "ftruncate complete" )
self._fflush()
def lock(self, cmd, owner, **kw):