Commit 00dd0e8a by bergquist

fix(plugins): fixes missed dist loading for plugindir

closes #4230
parent e7ef79e0
......@@ -89,12 +89,6 @@ func scan(pluginDir string) error {
pluginPath: pluginDir,
}
log.Info("Plugins: Scaning dir %s", pluginDir)
if util.ContainsDistFolder(pluginDir) {
log.Info("Plugins: Found dist folder in %s", pluginDir)
pluginDir = filepath.Join(pluginDir, "dist")
}
if err := util.Walk(pluginDir, true, true, scanner.walker); err != nil {
if pluginDir != "data/plugins" {
log.Warn("Could not scan dir \"%v\" error: %s", pluginDir, err)
......
......@@ -80,35 +80,50 @@ func walk(path string, info os.FileInfo, resolvedPath string, symlinkPathsFollow
if err != nil {
return walkFn(resolvedPath, info, err)
}
var subFiles = make([]subFile, 0)
for _, fileInfo := range list {
path2 := filepath.Join(path, fileInfo.Name())
var resolvedPath2 string
if resolvedPath != "" {
resolvedPath2 = filepath.Join(resolvedPath, fileInfo.Name())
}
err = walk(path2, fileInfo, resolvedPath2, symlinkPathsFollowed, walkFn)
subFiles = append(subFiles, subFile{path: path2, resolvedPath: resolvedPath2, fileInfo: fileInfo})
}
if containsDistFolder(subFiles) {
err := walk(
filepath.Join(path, "dist"),
info,
filepath.Join(resolvedPath, "dist"),
symlinkPathsFollowed,
walkFn)
if err != nil {
return err
}
} else {
for _, p := range subFiles {
err = walk(p.path, p.fileInfo, p.resolvedPath, symlinkPathsFollowed, walkFn)
if err != nil {
return err
}
}
}
return nil
}
return nil
}
func ContainsDistFolder(path string) bool {
info, err := os.Lstat(path)
if err != nil {
return false
}
if !info.IsDir() {
return false
}
type subFile struct {
path, resolvedPath string
fileInfo os.FileInfo
}
list, err := ioutil.ReadDir(path)
for _, fileInfo := range list {
if fileInfo.IsDir() && fileInfo.Name() == "dist" {
func containsDistFolder(subFiles []subFile) bool {
for _, p := range subFiles {
if p.fileInfo.IsDir() && p.fileInfo.Name() == "dist" {
return true
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment