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:
try:
mount_path = args[0][:1]
except IndexError:
self.error('Mount path required\n')
return 1
if windows: if windows:
try:
mount_path = args[0][:1]
except IndexError:
self.error('Driver letter\n')
return 1
from fs.expose import dokan from fs.expose import dokan
mount_path = mount_path[:1].upper() mount_path = mount_path[:1].upper()
dokan.unmount(mount_path) self.output('unmounting %s:\n' % mount_path, True)
self.output('unmounting %s:' % mount_path, True) dokan.unmount(mount_path)
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
fuse.unmount(mount_path) self.output('unmounting %s\n' % mount_path, True)
self.output('unmounting %s' % mount_path, True) fuse.unmount(mount_path)
return return
try: try:
...@@ -82,9 +92,7 @@ Mounts a file system on a system path""" ...@@ -82,9 +92,7 @@ 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 __setstate__(self, state): def __getstate__(self):
"""Pickle the TempFS. TempFS delted their contents when closed, so pickling # If we are picking a TempFS, we want to preserve its contents,
is not garanteed to preserve the directory contents""" # so we *don't* do the clean
state = super(TempFS, self).__setstate__(state) state = super(TempFS, self).__getstate__()
self._temp_dir = tempfile.mkdtemp(self.identifier or "TempFS", dir=self.temp_dir) self._cleaned = True
super(TempFS, self).__init__(self._temp_dir, return state
dir_mode=self.dir_mode,
thread_synchronize=self.thread_synchronize) def __setstate__(self, state):
state = super(TempFS, self).__setstate__(state)
self._cleaned = False
#self._temp_dir = tempfile.mkdtemp(self.identifier or "TempFS", dir=self.temp_dir)
#super(TempFS, self).__init__(self._temp_dir,
# dir_mode=self.dir_mode,
# thread_synchronize=self.thread_synchronize)
def close(self): def close(self):
"""Removes the temporary directory. """Removes the temporary directory.
......
...@@ -121,7 +121,7 @@ else: ...@@ -121,7 +121,7 @@ else:
class TestFUSE(unittest.TestCase,FSTestCases,ThreadingTestCases): class TestFUSE(unittest.TestCase,FSTestCases,ThreadingTestCases):
def setUp(self): def setUp(self):
self.temp_fs = TempFS() self.temp_fs = TempFS()
self.temp_fs.makedir("root") self.temp_fs.makedir("root")
self.temp_fs.makedir("mount") self.temp_fs.makedir("mount")
self.mounted_fs = self.temp_fs.opendir("root") self.mounted_fs = self.temp_fs.opendir("root")
......
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