aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-23 15:58:44 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-23 15:58:44 (GMT)
commite54a60a8e152d526e4f9ed7cfb3a8d400be70fe8 (patch)
tree29d647bd38cfeb08ec32dfa4bcb2869da61d094c
parent52e0eb015eca1d59b683adb27f8755f0fd51344c (diff)
downloadfusearchive-e54a60a8e152d526e4f9ed7cfb3a8d400be70fe8.zip
fusearchive-e54a60a8e152d526e4f9ed7cfb3a8d400be70fe8.tar.gz
fusearchive-e54a60a8e152d526e4f9ed7cfb3a8d400be70fe8.tar.bz2
Added gzip support
-rwxr-xr-xfusearchive.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 6680e3f..804991d 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -7,7 +7,8 @@
# See the file COPYING.
#
-import os, sys, shutil, fcntl, fuse, re, tempfile, sha, pickle
+import os, sys, shutil, fcntl, fuse, re
+import tempfile, sha, pickle, gzip
from errno import *
from stat import *
from fuse import Fuse
@@ -44,7 +45,7 @@ def inflate( src, dest ):
print "Unpickling: " + src
# TODO: return an IO error if inflating fails
- inp = open( src, "r" )
+ inp = gzip.open( src, "r" )
magic = pickle.load( inp )
inp.close()
print "Got data: " + str( magic )
@@ -70,7 +71,7 @@ def inflate( src, dest ):
if os.path.exists( "./storage/" + subpath ):
print "Exporting chunk"
- readchunk = open( "./storage/" + subpath )
+ readchunk = gzip.open( "./storage/" + subpath )
out.write( readchunk.read() )
readchunk.close()
else:
@@ -147,7 +148,7 @@ def deflate( src, dest ):
else:
# We found a spot, dump our data here
print "No block here, creating new block"
- savechunk = open( checkpath, "w" )
+ savechunk = gzip.open( checkpath, "w" )
savechunk.write( chunk )
savechunk.close
break
@@ -157,7 +158,7 @@ def deflate( src, dest ):
inp.close()
- out = open( dest, "w" )
+ out = gzip.open( dest, "w" )
pickle.dump( {
'stat': os.stat( src ),
'data': hashs
@@ -199,7 +200,7 @@ class FuseArchive(Fuse):
#pdb.set_trace()
# Override size
- inp = open( treefile )
+ inp = gzip.open( treefile )
magic = pickle.load( inp )
inp.close()