From 8b9aa09e8050545d1189753297961c917db8718b Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 3 Nov 2009 14:18:42 -0800 Subject: Only try and free the block refs if we are the last ref to the blocks so we don't do weird things when hardlinked, added note about rsync symlink utimens failures diff --git a/FuseArchive/FileSystem.py b/FuseArchive/FileSystem.py index 0d38f7b..fe793e1 100644 --- a/FuseArchive/FileSystem.py +++ b/FuseArchive/FileSystem.py @@ -47,11 +47,20 @@ class FileSystem(fuse.Fuse): yield fuse.Direntry(e) def unlink(self, path): - if os.path.isfile( path ) and not os.path.islink( path ): - # Ask our file to release it's chunks - f = ChunkFile( path, os.O_RDWR, 0 ) - f.pre_unlink() - f.release( 0 ) + # Check if we need to free our chunks + treefile = "./tree" + path + if os.path.isfile( treefile ): + if not os.path.islink( treefile ): + # it's a normal file, will the link cound go to zero here? + stats = os.stat( treefile ) + if stats.st_nlink == 1: + logging.debug( "Going to unlink file " + treefile + + "and this is the last link, releasing chunks" ) + # Ask our file to release it's chunks since we are the + # last link + f = ChunkFile( path, os.O_RDWR, 0 ) + f.pre_unlink() + f.release( 0 ) os.unlink("./tree" + path) @@ -89,6 +98,31 @@ class FileSystem(fuse.Fuse): def utime(self, path, times): os.utime("./tree" + path, times) +####### +# Following is the comment about utimens, however even uncommenting it +# doesn't currently work because there is an error in the fuse.py handling +# the message: +# +# Traceback (most recent call last): +# File "/usr/lib/python2.5/site-packages/fuse.py", line 361, in __call__ +# return apply(self.func, args, kw) +# File "/usr/lib/python2.5/site-packages/fuse.py", line 782, in wrap +# ts_acc = Timespec(tv_sec = acc_sec, tv_nsec = acc_nsec) +# TypeError: __init__() takes exactly 2 non-keyword arguments (1 given) +# +# Which if you use rsync makes it think the copy failed because it uses +# untimens to set the time info on symlinks (search google for utimens +# rsync symlink) +# +# I haven't been able to find a workaround for this yet, though there is +# some information at: +# +# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=455194 +# +# which suggests it should be fixed even though it doesn't appear to be for +# me in both lenny and squeeze +# +####### # The following utimens method would do the same as the above utime method. # We can't make it better though as the Python stdlib doesn't know of # subsecond preciseness in acces/modify times. -- cgit v0.10.2