Commit f64112a5 by willmcgugan

Fixes for fsmount

parent a32a775d
...@@ -40,21 +40,31 @@ Mounts a file system on a system path""" ...@@ -40,21 +40,31 @@ Mounts a file system on a system path"""
windows = platform == "Windows" windows = platform == "Windows"
if options.unmount: if options.unmount:
if windows:
try: try:
mount_path = args[0][:1] mount_path = args[0][:1]
except IndexError: except IndexError:
self.error('Mount path required\n') self.error('Driver letter\n')
return 1 return 1
if windows:
from fs.expose import dokan from fs.expose import dokan
mount_path = mount_path[:1].upper() mount_path = mount_path[:1].upper()
self.output('unmounting %s:\n' % mount_path, True)
dokan.unmount(mount_path) dokan.unmount(mount_path)
self.output('unmounting %s:' % mount_path, True)
return return
else: else:
try:
mount_path = args[0]
except IndexError:
self.error('Mount path required\n')
return 1
from fs.expose import fuse from fs.expose import fuse
self.output('unmounting %s\n' % mount_path, True)
fuse.unmount(mount_path) fuse.unmount(mount_path)
self.output('unmounting %s' % mount_path, True)
return return
try: try:
...@@ -82,8 +92,6 @@ Mounts a file system on a system path""" ...@@ -82,8 +92,6 @@ Mounts a file system on a system path"""
path = '/' path = '/'
if not options.nocache: if not options.nocache:
fs.cache_hint(True) fs.cache_hint(True)
if windows and not os.path.exists(mount_path):
os.makedirs(mount_path)
if windows: if windows:
from fs.expose import dokan from fs.expose import dokan
...@@ -92,7 +100,7 @@ Mounts a file system on a system path""" ...@@ -92,7 +100,7 @@ Mounts a file system on a system path"""
self.error('Driver letter should be one character') self.error('Driver letter should be one character')
return 1 return 1
self.output("Mounting %s on %s:" % (fs, mount_path), True) self.output("Mounting %s on %s:\n" % (fs, mount_path), True)
flags = dokan.DOKAN_OPTION_REMOVABLE flags = dokan.DOKAN_OPTION_REMOVABLE
if options.debug: if options.debug:
flags |= dokan.DOKAN_OPTION_DEBUG | dokan.DOKAN_OPTION_STDERR flags |= dokan.DOKAN_OPTION_DEBUG | dokan.DOKAN_OPTION_STDERR
...@@ -105,8 +113,12 @@ Mounts a file system on a system path""" ...@@ -105,8 +113,12 @@ Mounts a file system on a system path"""
volname=str(fs)) volname=str(fs))
else: else:
if not os.path.exists(mount_path):
os.makedirs(mount_path)
from fs.expose import fuse from fs.expose import fuse
self.output("Mounting %s on %s" % (fs, mount_path), True) self.output("Mounting %s on %s\n" % (fs, mount_path), True)
if options.foreground: if options.foreground:
fuse_process = fuse.mount(fs, fuse_process = fuse.mount(fs,
......
...@@ -56,14 +56,20 @@ class TempFS(OSFS): ...@@ -56,14 +56,20 @@ class TempFS(OSFS):
def __unicode__(self): def __unicode__(self):
return u'<TempFS: %s>' % self._temp_dir return u'<TempFS: %s>' % self._temp_dir
def __getstate__(self):
# If we are picking a TempFS, we want to preserve its contents,
# so we *don't* do the clean
state = super(TempFS, self).__getstate__()
self._cleaned = True
return state
def __setstate__(self, state): def __setstate__(self, state):
"""Pickle the TempFS. TempFS delted their contents when closed, so pickling
is not garanteed to preserve the directory contents"""
state = super(TempFS, self).__setstate__(state) state = super(TempFS, self).__setstate__(state)
self._temp_dir = tempfile.mkdtemp(self.identifier or "TempFS", dir=self.temp_dir) self._cleaned = False
super(TempFS, self).__init__(self._temp_dir, #self._temp_dir = tempfile.mkdtemp(self.identifier or "TempFS", dir=self.temp_dir)
dir_mode=self.dir_mode, #super(TempFS, self).__init__(self._temp_dir,
thread_synchronize=self.thread_synchronize) # dir_mode=self.dir_mode,
# thread_synchronize=self.thread_synchronize)
def close(self): def close(self):
"""Removes the temporary directory. """Removes the temporary directory.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment