unpack prepacked plugins on plugins initialization (#9149)
* unpack prepackaged plugins on plugins initialization * leverage utils.FindDir
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
f8f80d80df
Коммит
8948b91d7a
@@ -6,11 +6,13 @@ package app
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/mlog"
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/plugin"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func (a *App) SyncPluginsActiveState() {
|
||||
@@ -101,6 +103,25 @@ func (a *App) InitPlugins(pluginDir, webappPluginDir string) {
|
||||
a.Plugins = env
|
||||
}
|
||||
|
||||
prepackagedPluginsDir, found := utils.FindDir("prepackaged_plugins")
|
||||
if found {
|
||||
if err := filepath.Walk(prepackagedPluginsDir, func(walkPath string, info os.FileInfo, err error) error {
|
||||
if !strings.HasSuffix(walkPath, ".tar.gz") {
|
||||
return nil
|
||||
}
|
||||
|
||||
if fileReader, err := os.Open(walkPath); err != nil {
|
||||
mlog.Error("Failed to open prepackaged plugin", mlog.Err(err), mlog.String("path", walkPath))
|
||||
} else if _, err := a.InstallPlugin(fileReader, true); err != nil {
|
||||
mlog.Error("Failed to unpack prepackaged plugin", mlog.Err(err), mlog.String("path", walkPath))
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
mlog.Error("Failed to complete unpacking prepackaged plugins", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// Sync plugin active state when config changes. Also notify plugins.
|
||||
a.RemoveConfigListener(a.PluginConfigListenerId)
|
||||
a.PluginConfigListenerId = a.AddConfigListener(func(*model.Config, *model.Config) {
|
||||
|
||||
Ссылка в новой задаче
Block a user