aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-22 23:46:46 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-22 23:46:46 (GMT)
commitf0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12 (patch)
treed71064b799b169229b4fd74294d113b715a08b53
parent8572842c51475e1b7bf5061512ff670f047fdb19 (diff)
downloadfusearchive-f0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12.zip
fusearchive-f0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12.tar.gz
fusearchive-f0fa2ac7a4179dd9dd07237b53cbc65e5e6a5e12.tar.bz2
Initial attempt at inflating files
-rwxr-xr-xfusearchive.py39
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