aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfusearchive.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/fusearchive.py b/fusearchive.py
index 24beeeb..b427a5f 100755
--- a/fusearchive.py
+++ b/fusearchive.py
@@ -7,16 +7,12 @@
# See the file COPYING.
#
-import os, sys
+import os, sys, shutil, fcntl, fuse, re, tempfile
from errno import *
from stat import *
-import shutil
-import fcntl
-import fuse
-import re
-import tempfile
from fuse import Fuse
+import pdb
if not hasattr(fuse, '__version__'):
raise RuntimeError, \
@@ -151,19 +147,30 @@ class FuseArchive(Fuse):
print "Init file: " + path
self.orig_path = path;
( fdnum, self.tmp_name ) = tempfile.mkstemp();
- os.close( fdnum );
+ #os.close( fdnum );
- if os.path.exists( ".tree/" + self.orig_path ):
- shutil.copy( ".tree/" + path, self.tmp_name )
+ if os.path.exists( "./tree" + self.orig_path ):
+ shutil.copy( "./tree" + path, self.tmp_name )
print "Shadow file: " + self.tmp_name + " for " + self.orig_path
- self.file = os.fdopen( os.open( self.tmp_name, flags, *mode),
- flag2mode(flags))
+ print "Going to open shadow file with flags: " + str(flags) + " mode " + str(mode)
+ # pdb.set_trace()
+ print "Flag2mode is: " + str( flag2mode( flags ) )
+
+ # Just use the fdnum they gave us instead of reopening it,
+ # since that might fail
+ # fdnum = os.open( self.tmp_name, flags, *mode )
+ #print "Got fdnum: " + str(fdnum)
+ self.file = os.fdopen( fdnum, flag2mode( flags ) )
+ print "Open"
+
self.fd = self.file.fileno()
self.direct_io = False
self.keep_cache = False
+ print str(self) + " init complete"
+
def read(self, length, offset):
print "Reading from " + self.orig_path
self.file.seek(offset)
@@ -183,7 +190,8 @@ class FuseArchive(Fuse):
print "Copying working file back to storage: " + \
self.tmp_name + " -> " + self.orig_path
- shutil.copy( self.tmp_name, ".tree/" + self.orig_path );
+ #pdb.set_trace()
+ shutil.copy( self.tmp_name, "./tree" + self.orig_path );
print "Deleting old file: " + self.tmp_name
os.unlink( self.tmp_name );