diff options
-rwxr-xr-x | fusearchive.py | 25 |
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""" |