diff --git a/app/plugin_install.go b/app/plugin_install.go index 8fbd0bc623..de5928b683 100644 --- a/app/plugin_install.go +++ b/app/plugin_install.go @@ -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)) }