From e54a60a8e152d526e4f9ed7cfb3a8d400be70fe8 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Thu, 23 Jul 2009 08:58:44 -0700 Subject: Added gzip support 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() -- cgit v0.10.2