diff options
-rwxr-xr-x | fusearchive.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/fusearchive.py b/fusearchive.py index 032f0e9..86297f5 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -40,6 +40,45 @@ def flag2mode(flags): def inflate( src, dest ): print "inflate!" + out = open( dest, "w" ) + + print "Unpickling: " + src + # TODO: return an IO error if inflating fails + inp = open( src, "r" ) + magic = pickle.load( inp ) + inp.close() + print "Got data: " + str( magic ) + + #pdb.set_trace() + + # Now unserialize the chunks back in to a file + for key in magic[ 'data' ]: + ( hash, seq ) = key + + chars = list( hash ) + print chars + + # Todo: make a digest -> path function to share with deflate + hexdigest = ''.join( [ "%02x" % ord( x ) for x in chars ] ); + subparts = [ "%02x" % ord( x ) for x in chars[ :magic_depth ] ] + subpath = '/'.join( subparts ); + print "Subpath: " + subpath + + subpath += "/" + hexdigest + "_" + str( seq ); + + print "Chunk path: " + subpath + + if os.path.exists( "./storage/" + subpath ): + print "Exporting chunk" + readchunk = open( "./storage/" + subpath ) + out.write( readchunk.read() ) + readchunk.close() + else: + raise IOError + + print "File inflated" + out.close() + # TODO: deflate only if the file has been modified # Deflate a file, src is the unpacked file, dest is where we want to pack |