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 all commits
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 @@ -267,6 +267,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 @@ -184,6 +184,9 @@ def unmount(self, profileID = None):
"""
return

def postUnmount(self, profileID = None):
return

class PluginManager:
""" Central interface for loading plugins and calling their API

Expand Down Expand Up @@ -342,6 +345,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 @@ -138,3 +138,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)