diff options
Diffstat (limited to 'fusearchive.py')
-rwxr-xr-x | fusearchive.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fusearchive.py b/fusearchive.py index 53a2d09..a1d737e 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -26,7 +26,7 @@ fuse.feature_assert('stateful_files', 'has_init') magic_blocksize = 1024 * 128 magic_depth = 5 -debug_level = 0 +debug_level = 3 gzip_compress_level = 6 # Memory for dirty blocks, per file (1M) @@ -76,7 +76,7 @@ def save_chunk( chunk ): dmsg( 3, "Checking: " + checkpath ) if os.path.exists( checkpath ): # Check if this is our data - verify = FuseArchiveWriter.open( checkpath, "rb" ) + verify = FuseArchiveStream.open( checkpath, "rb" ) verify_contents = verify.read() verify.close() @@ -89,7 +89,7 @@ def save_chunk( chunk ): else: # We found a spot, dump our data here dmsg( 3, "No block here, creating new block" ) - savechunk = FuseArchiveWriter.open( checkpath, "wb" ) + savechunk = FuseArchiveStream.open( checkpath, "wb" ) savechunk.write( chunk ) savechunk.close break @@ -118,7 +118,7 @@ def load_chunk( key ): if os.path.exists( "./storage/" + subpath ): dmsg( 3, "Exporting chunk" ) - readchunk = FuseArchiveWriter.open( "./storage/" + subpath ) + readchunk = FuseArchiveStream.open( "./storage/" + subpath ) chunk = readchunk.read() readchunk.close() else: @@ -126,7 +126,7 @@ def load_chunk( key ): return chunk -class FuseArchiveWriter: +class FuseArchiveStream: """This just allows switching out writer classes easily""" @staticmethod def open( path, mode = 'r' ): @@ -137,13 +137,13 @@ class FuseArchiveSerializer: """This lets us experiment with different main file serializers""" @staticmethod def dump( file, obj ): - out = FuseArchiveWriter.open( file, "wb" ) + out = FuseArchiveStream.open( file, "wb" ) cPickle.dump( obj, out, -1 ) # new file format out.close() @staticmethod def load( file ): - inp = FuseArchiveWriter.open( file, "rb" ) + inp = FuseArchiveStream.open( file, "rb" ) magic = cPickle.load( inp ) inp.close() return magic @@ -442,7 +442,7 @@ class FuseArchive(Fuse): dmsg( 3, "Copying " + str(to_read) + " bytes" ) - data += self.chunk[ rest:chunk_remaining ] + data += self.chunk[ rest:to_read ] data_read += to_read index += 1 rest = 0 @@ -450,6 +450,8 @@ class FuseArchive(Fuse): dmsg( 3, "No more chunk data, bye" ) is_eof = True + dmsg( 3, "Returning " + str( len( data ) ) + " bytes of data" ) + dmsg( 3, "Internal count was: " + str( data_read ) ) return data def write(self, buf, offset): |