From f0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Wed, 22 Jul 2009 16:46:46 -0700 Subject: Initial attempt at inflating files 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 -- cgit v0.10.2