From b90720764eab6c999fe7a4ef5169bb82fb080c22 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Thu, 23 Jul 2009 09:53:57 -0700 Subject: Only save if file was modified diff --git a/fusearchive.py b/fusearchive.py index 328ee49..b1ebc36 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -360,6 +360,7 @@ class FuseArchive(Fuse): dmsg( 2, "Writing to " + self.orig_path ) self.file.seek(offset) self.file.write(buf) + self.modified = True return len(buf) def release(self, flags): @@ -367,11 +368,14 @@ class FuseArchive(Fuse): dmsg( 2, "Release: " + self.orig_path ) self.file.close() - dmsg( 2, "Copying working file back to storage: " + \ - self.tmp_name + " -> " + self.orig_path ) + if self.modified: + dmsg( 2, "Copying working file back to storage: " + \ + self.tmp_name + " -> " + self.orig_path ) - #pdb.set_trace() - deflate( self.tmp_name, "./tree" + self.orig_path ); + #pdb.set_trace() + deflate( self.tmp_name, "./tree" + self.orig_path ) + else: + dmsg( 2, "File not modified, not copying back" ) dmsg( 2, "Deleting old file: " + self.tmp_name ) os.unlink( self.tmp_name ); @@ -396,6 +400,7 @@ class FuseArchive(Fuse): return os.fstat(self.fd) def ftruncate(self, len): + self.modified = True self.file.truncate(len) def lock(self, cmd, owner, **kw): -- cgit v0.10.2