diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2009-07-24 15:40:21 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2009-07-24 15:40:21 (GMT) |
commit | 6dcbdeb1c404acf0e5a7730d756b4be931d23ef1 (patch) | |
tree | d668de179212ce2ea226e70e08dd26b49122af26 | |
parent | 03d8138e65e2526325cb9aa4a2c4d1211e0b3b43 (diff) | |
download | fusearchive-6dcbdeb1c404acf0e5a7730d756b4be931d23ef1.zip fusearchive-6dcbdeb1c404acf0e5a7730d756b4be931d23ef1.tar.gz fusearchive-6dcbdeb1c404acf0e5a7730d756b4be931d23ef1.tar.bz2 |
Fix a huge bug with reading data blocks sometimes returning more data than
the caller requested, renamed fusearechivewriter to fusearchivestream
because it's for both reading and writing
-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): |