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.
Этот коммит содержится в:
@@ -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)
|
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()
|
bundles, err := pluginsEnvironment.Available()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, model.NewAppError("installPlugin", "app.plugin.install.app_error", nil, err.Error(), http.StatusInternalServerError)
|
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)
|
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 {
|
if err := a.notifyPluginStatusesChanged(); err != nil {
|
||||||
mlog.Error("failed to notify plugin status changed", mlog.Err(err))
|
mlog.Error("failed to notify plugin status changed", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user