aboutsummaryrefslogtreecommitdiffstats
path: root/fusearchive.py
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2009-07-23 23:53:52 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2009-07-23 23:53:52 (GMT)
commit61a94933a92d01fbea324e23335d0fe28b68dba9 (patch)
tree977ebf1f22e1a7f83c074d962c3ae9e1dccec242 /fusearchive.py
parent053804b9b1118555f36ac62a6477d20e06029307 (diff)
downloadfusearchive-61a94933a92d01fbea324e23335d0fe28b68dba9.zip
fusearchive-61a94933a92d01fbea324e23335d0fe28b68dba9.tar.gz
fusearchive-61a94933a92d01fbea324e23335d0fe28b68dba9.tar.bz2
Added binary flag and gzip compression level
Diffstat (limited to 'fusearchive.py')
-rwxr-xr-xfusearchive.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/fusearchive.py b/fusearchive.py
index c4e3811..0609124 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -26,7 +26,8 @@ fuse.feature_assert('stateful_files', 'has_init')
magic_blocksize = 1024 * 128
magic_depth = 5
-debug_level = 3
+debug_level = 0
+gzip_compress_level = 1
# Memory for dirty blocks, per file (1M)
dirty_size = 1024 * 1024 * 1;
@@ -42,7 +43,7 @@ def dmsg(level,message):
def save_chunk( chunk ):
dmsg( 2, "Begin save_chunk" )
# Save this hash string, similar to the backuppc algo
- digest = sha.new( str(len(chunk)) + chunk ).digest()
+ digest = sha.new( chunk ).digest()
# Write out our chunk
chars = list( digest )
@@ -75,7 +76,7 @@ def save_chunk( chunk ):
dmsg( 3, "Checking: " + checkpath )
if os.path.exists( checkpath ):
# Check if this is our data
- verify = gzip.open( checkpath, "r" )
+ verify = gzip.open( checkpath, "rb" )
verify_contents = verify.read()
verify.close()
@@ -88,7 +89,7 @@ def save_chunk( chunk ):
else:
# We found a spot, dump our data here
dmsg( 3, "No block here, creating new block" )
- savechunk = gzip.open( checkpath, "w" )
+ savechunk = gzip.open( checkpath, "wb", gzip_compress_level )
savechunk.write( chunk )
savechunk.close
break
@@ -314,7 +315,7 @@ class FuseArchive(Fuse):
src = "./tree" + self.orig_path
dmsg( 3, "Unpickling: " + src )
# TODO: return an IO error if inflating fails
- inp = gzip.open( src, "r" )
+ inp = gzip.open( src, "rb" )
magic = pickle.load( inp )
inp.close()
dmsg( 3, "Got data: " + str( magic ) )
@@ -503,7 +504,7 @@ class FuseArchive(Fuse):
dmsg( 3, "Size calculated is: " + str( self.size ) )
- out = gzip.open( "./tree" + self.orig_path, "w" )
+ out = gzip.open( "./tree" + self.orig_path, "wb", gzip_compress_level )
pickle.dump( {
'size': self.size,
'chunks': self.chunks,
@@ -543,7 +544,7 @@ class FuseArchive(Fuse):
def ftruncate(self, len):
if len > 0:
- print "WARNING: ftruncate is broken!!!"
+ print "WARNING: ftruncate is broken for non-zero len!!!"
self.chunks = []
self.modified = True