Update static files when installing or uninstalling a plugin

This commit is contained in:
Oliver Walters 2024-08-13 07:27:18 +00:00
parent e4852b8b1b
commit 69057d98f7
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs):
"""Run the management command."""
from plugin.staticfiles import collect_plugins_static_files
import plugin.staticfiles
collect_plugins_static_files()
plugin.staticfiles.collect_plugins_static_files()
plugin.staticfiles.clear_plugins_static_files()

View File

@ -269,6 +269,9 @@ def install_plugin(url=None, packagename=None, user=None, version=None):
registry.reload_plugins(full_reload=True, force_reload=True, collect=True)
# Update static files
plugin.staticfiles.collect_plugins_static_files()
return ret
@ -333,6 +336,9 @@ def uninstall_plugin(cfg: plugin.models.PluginConfig, user=None, delete_config=T
# Remove the plugin configuration from the database
cfg.delete()
# Remove static files associated with this plugin
plugin.staticfiles.clear_static_dir(f'plugins/{cfg.key}/', recursive=True)
# Reload the plugin registry
registry.reload_plugins(full_reload=True, force_reload=True, collect=True)