aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfusearchive.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 41d0ad9..574c630 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -50,7 +50,7 @@ def flag2mode(flags):
md = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'}
m = md[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)]
- if flags | os.O_APPEND:
+ if flags & os.O_APPEND:
m = m.replace('w', 'a', 1)
return m
@@ -304,7 +304,6 @@ class FuseArchiveSerializer:
fh.seek( 0 )
f = gzip.GzipFile( None, "rb", gzip_compress_level, fh )
#f = fh
- #pdb.set_trace()
magic = cPickle.load( f )
return( magic )
@@ -382,9 +381,8 @@ class FuseArchive(Fuse):
def truncate(self, path, len):
# Truncate using the ftruncate on the file
- pdb.set_trace()
logging.debug( "Using FuseArchiveFile to truncate " + path + " to " + str(len) )
- f = self.FuseArchiveFile( path, os.O_WRONLY | os.O_APPEND, 0 )
+ f = self.FuseArchiveFile( path, os.O_RDWR, 0 )
f.ftruncate(len)
f.release( 0 )
@@ -509,11 +507,14 @@ class FuseArchive(Fuse):
# Read in file info table
logging.debug( "Unpickling: " + str( self.file ) )
# TODO: return an IO error if inflating fails
- magic = FuseArchiveSerializer.loadfh( self.file )
- logging.debug( "Got data: " + str( magic ) )
- self.size = magic[ 'size' ]
- self.chunks = magic[ 'chunks' ]
- self.chunk_size = magic[ 'chunk_size' ]
+ try:
+ magic = FuseArchiveSerializer.loadfh( self.file )
+ logging.debug( "Got data: " + str( magic ) )
+ self.size = magic[ 'size' ]
+ self.chunks = magic[ 'chunks' ]
+ self.chunk_size = magic[ 'chunk_size' ]
+ except Exception, e:
+ logger.critical( e )
else:
if self.wr:
logging.debug( "File doesn't exist and we're going to write, creating temp empty file" )
@@ -523,7 +524,6 @@ class FuseArchive(Fuse):
self.direct_io = False
self.keep_cache = False
- #pdb.set_trace()
logging.debug( str(self) + " init complete" )
def _load_chunk( self, index ):
@@ -687,7 +687,6 @@ class FuseArchive(Fuse):
# can with splice() we will reconstruct the data by joining
# stuff by offsets (first chars to skip, then our joining
# buf chunk, the everything that would have been after it)
- #pdb.set_trace()
self.chunk = self.chunk[ :rest ] + \
buf[ buf_offset:(buf_offset+this_len) ] + \
self.chunk[ (rest + this_len): ]
@@ -801,7 +800,6 @@ class FuseArchive(Fuse):
self._load_chunk( 0 )
- #pdb.set_trace()
if need_chunks == 0:
logging.debug( "Creating 0 chunk file" )
self.chunks = []