aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--FuseArchive/ChunkFile.py53
1 files changed, 30 insertions, 23 deletions
diff --git a/FuseArchive/ChunkFile.py b/FuseArchive/ChunkFile.py
index ac39439..5432f3b 100644
--- a/FuseArchive/ChunkFile.py
+++ b/FuseArchive/ChunkFile.py
@@ -214,29 +214,6 @@ class ChunkFile(object):
logging.debug( "Key was %s" % key )
self.dirty_chunks = 0
- # Is this chunk changed from what was here before?
- oldkey = None
- key = self.chunks[ index ]
-
- changed = False
- # Is the old chunks at least this big?
- if index >= len( self.original_chunks ):
- logging.debug( "No old chunk at this spot, changed for sure" )
- changed = True
- else:
- oldkey = self.original_chunks[ index ]
- if oldkey != key:
- logging.debug( "Key has changed at index %d" % index )
- changed = True
- logging.debug( "%s is now %s" % (oldkey, key) )
-
- if changed:
- logging.debug( "Chunk at index %d has changed" % index )
- if oldkey != None:
- unlock_chunk( oldkey )
-
- lock_chunk( key )
-
def read(self, length, offset):
logging.debug( "Reading from %s offset: %d (0x%x) length: %d (0x%d)" %
( self.orig_path, offset, offset, length, length ) )
@@ -424,6 +401,36 @@ class ChunkFile(object):
'chunk_size': self.chunk_size
} )
+ # Now update our chunk ref counts
+ logging.debug( "Updating chunk references" )
+ for index in range( len( self.chunks ) ):
+ # Is this chunk changed from what was here before?
+ oldkey = None
+ key = self.chunks[ index ]
+
+ changed = False
+ # Is the old chunks at least this big?
+ if index >= len( self.original_chunks ):
+ logging.debug( "No old chunk at this spot, changed for sure" )
+ changed = True
+ else:
+ oldkey = self.original_chunks[ index ]
+ if oldkey != key:
+ logging.debug( "Key has changed at index %d" % index )
+ changed = True
+ logging.debug( "%s is now %s" % (oldkey, key) )
+
+ if changed:
+ logging.debug( "Chunk at index %d has changed" % index )
+ if oldkey != None:
+ unlock_chunk( oldkey )
+
+ lock_chunk( key )
+
+ # Update our original_chunks since we've locked/unlocked some
+ # things
+ self.original_chunks = copy.deepcopy( self.chunks )
+
# Not dirty anymore
if self.orig_path in dirty_cache:
del dirty_cache[ self.orig_path ]