aboutsummaryrefslogtreecommitdiffstats
path: root/FuseArchive/FileSystem.py
diff options
context:
space:
mode:
Diffstat (limited to 'FuseArchive/FileSystem.py')
-rw-r--r--FuseArchive/FileSystem.py44
1 files changed, 39 insertions, 5 deletions
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.