aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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