diff options
author | Jesse Hallam <jesse.hallam@gmail.com> | 2018-07-31 16:29:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-31 16:29:52 -0400 |
commit | 0788cdcadfb5d76b08758f42f01521b45ea76362 (patch) | |
tree | 86efb424a0543571398866e3cb84ee38be101141 /app/plugin.go | |
parent | 8c56f52d17d73a431a060919c97fe8939f81a0d1 (diff) | |
download | chat-0788cdcadfb5d76b08758f42f01521b45ea76362.tar.gz chat-0788cdcadfb5d76b08758f42f01521b45ea76362.tar.bz2 chat-0788cdcadfb5d76b08758f42f01521b45ea76362.zip |
MM-11420: plugins: compute bundle hash on load (#9172)
* plugins: compute bundle hash on load
Use this hash to bust client caches whenever the plugin bundle changes.
* eliminate redundant pluginHandler
* switch to 64-bit FNV-1a
* Fix test
Diffstat (limited to 'app/plugin.go')
-rw-r--r-- | app/plugin.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/app/plugin.go b/app/plugin.go index 8838e31a9..51e67e2bf 100644 --- a/app/plugin.go +++ b/app/plugin.go @@ -40,7 +40,12 @@ func (a *App) SyncPluginsActiveState() { // If it's not enabled we need to deactivate it if !pluginEnabled { - a.Plugins.Deactivate(pluginId) + deactivated := a.Plugins.Deactivate(pluginId) + if deactivated && plugin.Manifest.HasClient() { + message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil) + message.Add("manifest", plugin.Manifest.ClientManifest()) + a.Publish(message) + } } } @@ -60,8 +65,16 @@ func (a *App) SyncPluginsActiveState() { // Activate plugin if enabled if pluginEnabled { - if err := a.Plugins.Activate(pluginId); err != nil { + updatedManifest, activated, err := a.Plugins.Activate(pluginId) + if err != nil { plugin.WrapLogger(a.Log).Error("Unable to activate plugin", mlog.Err(err)) + continue + } + + if activated && updatedManifest.HasClient() { + message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_ENABLED, "", "", "", nil) + message.Add("manifest", updatedManifest.ClientManifest()) + a.Publish(message) } } } @@ -194,12 +207,6 @@ func (a *App) EnablePlugin(id string) *model.AppError { cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: true} }) - if manifest.HasClient() { - message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_ENABLED, "", "", "", nil) - message.Add("manifest", manifest.ClientManifest()) - a.Publish(message) - } - // This call will cause SyncPluginsActiveState to be called and the plugin to be activated if err := a.SaveConfig(a.Config(), true); err != nil { if err.Id == "ent.cluster.save_config.error" { @@ -240,12 +247,6 @@ func (a *App) DisablePlugin(id string) *model.AppError { cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: false} }) - if manifest.HasClient() { - message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_PLUGIN_DISABLED, "", "", "", nil) - message.Add("manifest", manifest.ClientManifest()) - a.Publish(message) - } - if err := a.SaveConfig(a.Config(), true); err != nil { return model.NewAppError("DisablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError) } |