aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-28 04:32:22 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-28 04:32:22 (GMT)
commitdf7b0a0a0e29b4b8285da704970869eca0422cd5 (patch)
tree538a44993552734e29adf398c28f6323128e6876
parent0e331018ad18846522ba833842867e40ef14c69a (diff)
downloadfusearchive-df7b0a0a0e29b4b8285da704970869eca0422cd5.zip
fusearchive-df7b0a0a0e29b4b8285da704970869eca0422cd5.tar.gz
fusearchive-df7b0a0a0e29b4b8285da704970869eca0422cd5.tar.bz2
A workaround attempt to fix opening a file for writing then changing it to
R/O later (happens with cp -a, etc)
-rwxr-xr-xfusearchive.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 2ed69ed..13d56dd 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -8,7 +8,7 @@
# See the file COPYING.
#
-import os, sys, fcntl, fuse, sha, cPickle, gzip, errno, zipfile
+import os, sys, fcntl, fuse, sha, cPickle, gzip, errno, zipfile, stat
from fuse import Fuse
import pdb
@@ -257,8 +257,27 @@ class FuseArchiveStream:
"""This just allows switching out writer classes easily"""
@staticmethod
def open( path, mode = 'r' ):
- return gzip.open( path, mode, gzip_compress_level )
- #return open( path, mode )
+ # This was added to fix the case of copying a read-only file, cp
+ # will create the new file then it gets chmod or something but we
+ # don't keep an fh around to write to later, we open and close it
+ # every time we need to update the file info. We should keep an fh
+ # around from creation time and use that instead though and allow
+ # passing an fh here instead of a filename
+ if os.path.exists( path ):
+ st = os.stat( path )
+ # Make it writable
+ os.chmod( path, stat.S_IWUSR )
+ else:
+ st = None
+
+ fh = gzip.open( path, mode, gzip_compress_level )
+
+ if st:
+ # Reset permissions
+ os.chmod( path, st.st_mode )
+
+ #fh = open( path, mode )
+ return fh
class FuseArchiveSerializer:
"""This lets us experiment with different main file serializers"""