mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-8662: Preserve plugin's enabled state when overwriting (#10005)
If a plugin upload overwrites an exiosting plugin, the new one will be immediately enabled if the old one was enabled.
This commit is contained in:
@@ -56,6 +56,9 @@ func (a *App) installPlugin(pluginFile io.Reader, replace bool) (*model.Manifest
|
||||
return nil, model.NewAppError("installPlugin", "app.plugin.invalid_id.app_error", map[string]interface{}{"Min": plugin.MinIdLength, "Max": plugin.MaxIdLength, "Regex": plugin.ValidIdRegex}, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// Stash the previous state of the plugin, if available
|
||||
stashed := a.Config().PluginSettings.PluginStates[manifest.Id]
|
||||
|
||||
bundles, err := pluginsEnvironment.Available()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("installPlugin", "app.plugin.install.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -80,6 +83,10 @@ func (a *App) installPlugin(pluginFile io.Reader, replace bool) (*model.Manifest
|
||||
return nil, model.NewAppError("installPlugin", "app.plugin.mvdir.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if stashed != nil && stashed.Enable {
|
||||
a.EnablePlugin(manifest.Id)
|
||||
}
|
||||
|
||||
if err := a.notifyPluginStatusesChanged(); err != nil {
|
||||
mlog.Error("failed to notify plugin status changed", mlog.Err(err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user