diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2009-08-07 05:39:44 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2009-08-07 05:39:44 (GMT) |
commit | 16b950060f30fd1793608d2b14f2de235b0d8c83 (patch) | |
tree | f767dfa09f86de6dbcbf028eb96ba97dfb791b2c /FuseArchive/Serializer.py | |
parent | 706fd70f3464a8b8216880cdd238508d0bdd5215 (diff) | |
download | fusearchive-16b950060f30fd1793608d2b14f2de235b0d8c83.zip fusearchive-16b950060f30fd1793608d2b14f2de235b0d8c83.tar.gz fusearchive-16b950060f30fd1793608d2b14f2de235b0d8c83.tar.bz2 |
Store a key in the phyiscal file that pulls the data from a chunk to
minimize 100% file duplicates to be nothing more than a key length
Diffstat (limited to 'FuseArchive/Serializer.py')
-rw-r--r-- | FuseArchive/Serializer.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/FuseArchive/Serializer.py b/FuseArchive/Serializer.py index b23371c..621d90a 100644 --- a/FuseArchive/Serializer.py +++ b/FuseArchive/Serializer.py @@ -17,11 +17,15 @@ class Serializer: fh.seek( 0 ) f = gzip.GzipFile( None, "wb", gzip_compress_level, fh ) #f = fh - cPickle.dump( obj, f, -1 ) + f.write( Serializer.dumps( obj ) ) del f fh.flush() @staticmethod + def dumps( obj ): + return cPickle.dumps( obj, -1 ) + + @staticmethod def load( f ): if FuseArchive.magic_profiling: return { 'size': 0, 'chunks': 0, 'chunk_size': 0 } @@ -37,6 +41,9 @@ class Serializer: fh.seek( 0 ) f = gzip.GzipFile( None, "rb", gzip_compress_level, fh ) #f = fh - magic = cPickle.load( f ) + magic = Serializer.loads( f.read() ) return( magic ) + @staticmethod + def loads( str ): + return cPickle.loads( str ) |