From 67bfdae92465ba23b1a8140b329710773d2738b8 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 28 Jul 2009 09:26:35 -0700 Subject: Added an exception printer on the file setup since it seems to crash there a lot when there are file serialization problems 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 = [] -- cgit v0.10.2