aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive
diff options
context:
space:
mode:
Diffstat (limited to 'FuseArchive')
-rw-r--r--FuseArchive/ChunkFile.py13
-rw-r--r--FuseArchive/FileSystem.py2
2 files changed, 14 insertions, 1 deletions
diff --git a/FuseArchive/ChunkFile.py b/FuseArchive/ChunkFile.py
index 5432f3b..e713e10 100644
--- a/FuseArchive/ChunkFile.py
+++ b/FuseArchive/ChunkFile.py
@@ -87,6 +87,11 @@ class ChunkFile(object):
# The chunk table
self.chunks = []
+ # Because python is bizarre and you magically define attributes in
+ # the constructor we predefine this here for the case where we
+ # fflush early if we're creating a new file since we reference this
+ # attribute in the routine. At least it gets initialized I guess
+ self.original_chunks = []
# TODO: Better flag handling here?
if flags & os.O_RDONLY:
@@ -427,6 +432,14 @@ class ChunkFile(object):
lock_chunk( key )
+ # Free any unused chunks because of ftruncate
+ logging.debug( "Freeing chunks beyond our new chunk count" )
+ index = len( self.chunks )
+ while index < len( self.original_chunks ):
+ logging.debug( "Unlocking chunk at index %d" % index )
+ unlock_chunk( self.original_chunks[ index ] )
+ index += 1
+
# Update our original_chunks since we've locked/unlocked some
# things
self.original_chunks = copy.deepcopy( self.chunks )
diff --git a/FuseArchive/FileSystem.py b/FuseArchive/FileSystem.py
index e70bba6..16e5b2c 100644
--- a/FuseArchive/FileSystem.py
+++ b/FuseArchive/FileSystem.py
@@ -49,7 +49,7 @@ class FileSystem(fuse.Fuse):
def unlink(self, path):
# Do a truncate to free our chunks
f = ChunkFile( path, os.O_RDWR, 0 )
- f.truncate( 0 )
+ f.ftruncate( 0 )
f.release( 0 )
os.unlink("./tree" + path)