aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-08-06 23:29:24 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-08-06 23:29:24 (GMT)
commite3f46ccfb21bb988e2649a6c54daba9dec2c9a03 (patch)
tree78d30ea5569a5202f6ccd19ba86d4397670aecfb /FuseArchive
parent48c3c17f734f2e548b6c8d0d75a0060306a75ee6 (diff)
downloadfusearchive-e3f46ccfb21bb988e2649a6c54daba9dec2c9a03.zip
fusearchive-e3f46ccfb21bb988e2649a6c54daba9dec2c9a03.tar.gz
fusearchive-e3f46ccfb21bb988e2649a6c54daba9dec2c9a03.tar.bz2
Update chunk ref counts when we update the on-disk chunk list
Diffstat (limited to 'FuseArchive')
-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 ]