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
Этот коммит содержится в:
Jesse Hallam
2018-07-31 16:29:52 -04:00
коммит произвёл GitHub
родитель 8c56f52d17
Коммит 0788cdcadf
5 изменённых файлов: 58 добавлений и 54 удалений

Просмотреть файл

@@ -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)
}