Skip to content

Commit

Permalink
Add postUnmount plugin callback
Browse files Browse the repository at this point in the history
This is useful for unmounting the remote drive over ssh after sshfs
is unmounted.

If the remote drive is unmounted before sshfs with the existing callback,
then sshfs can not be unmounted and the mountpoint shows up as
d????????? ? ?         ?            ?            ? mountpoint
until the remote drive is remounted.
  • Loading branch information
tatokis committed Aug 9, 2022
1 parent 29e874f commit 76a4b1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def umount(self, hash_id = None):
parent = self.parent,
**kwargs)
backend.umount()
self.config.PLUGIN_MANAGER.postUnmount(self.profile_id)

def preMountCheck(self, mode = None, first_run = False, **kwargs):
"""
Expand Down
10 changes: 10 additions & 0 deletions common/pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def mount(self, profileID = None):
def unmount(self, profileID = None):
return

def postUnmount(self, profileID = None):
return

class PluginManager:
def __init__(self):
self.plugins = []
Expand Down Expand Up @@ -180,6 +183,13 @@ def unmount(self, profileID = None):
except BaseException as e:
self.logError(plugin, e)

def postUnmount(self, profileID = None):
for plugin in reversed(self.plugins):
try:
plugin.postUnmount(profileID)
except BaseException as e:
self.logError(plugin, e)

def logError(self, plugin, e):
logger.error('Plugin %s %s failed: %s'
%(plugin.__module__, #plugin name
Expand Down
3 changes: 3 additions & 0 deletions common/plugins/usercallbackplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ def mount(self, profileID = None):

def unmount(self, profileID = None):
self.callback('8', profileID = profileID)

def postUnmount(self, profileID = None):
self.callback('9', profileID = profileID)

0 comments on commit 76a4b1b

Please sign in to comment.