Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add postUnmount plugin callback #1269

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)