From 76a4b1bc1e0df8344069c15f5ec9b13cad688243 Mon Sep 17 00:00:00 2001 From: Tasos Sahanidis Date: Tue, 9 Aug 2022 04:24:36 +0300 Subject: [PATCH] Add postUnmount plugin callback 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. --- common/mount.py | 1 + common/pluginmanager.py | 10 ++++++++++ common/plugins/usercallbackplugin.py | 3 +++ 3 files changed, 14 insertions(+) diff --git a/common/mount.py b/common/mount.py index 4b68ee60b..f9592766c 100644 --- a/common/mount.py +++ b/common/mount.py @@ -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): """ diff --git a/common/pluginmanager.py b/common/pluginmanager.py index 86bae8f28..54713cc70 100644 --- a/common/pluginmanager.py +++ b/common/pluginmanager.py @@ -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 = [] @@ -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 diff --git a/common/plugins/usercallbackplugin.py b/common/plugins/usercallbackplugin.py index 1349ef38d..11fdedbe2 100644 --- a/common/plugins/usercallbackplugin.py +++ b/common/plugins/usercallbackplugin.py @@ -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)