[v9.5.x] Plugins: Fix module.js file not being closed when loading plugins (#66435)
* Plugins: Fix module.js file not being closed when loading plugins (#66288)
* Plugins: Loader: Fix module.js file not being closed
* Plugins: LocalFS: Add comments, ensure same Read() behaviour as os.File's
* Changed comment for Close()
* Add tests for LocalFS
* "Fix" linter error
* "Fix" linter error again
(cherry picked from commit 1c3ad81826)
* trigger ci
---------
Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>
Co-authored-by: Giuseppe Guerra <to@nyo.zz.mu>
This commit is contained in:
co-authored by
Giuseppe Guerra
Giuseppe Guerra
parent
0f10b98202
commit
0f4a76c9de
@@ -152,12 +152,16 @@ func (l *Loader) loadPlugins(ctx context.Context, src plugins.PluginSource, foun
|
||||
// verify module.js exists for SystemJS to load.
|
||||
// CDN plugins can be loaded with plugin.json only, so do not warn for those.
|
||||
if !plugin.IsRenderer() && !plugin.IsCorePlugin() {
|
||||
_, err := plugin.FS.Open("module.js")
|
||||
f, err := plugin.FS.Open("module.js")
|
||||
if err != nil {
|
||||
if errors.Is(err, plugins.ErrFileNotExist) && !l.pluginsCDN.PluginSupported(plugin.ID) {
|
||||
l.log.Warn("Plugin missing module.js", "pluginID", plugin.ID,
|
||||
"warning", "Missing module.js, If you loaded this plugin from git, make sure to compile it.")
|
||||
}
|
||||
} else if f != nil {
|
||||
if err := f.Close(); err != nil {
|
||||
l.log.Warn("Could not close module.js", "pluginID", plugin.ID, "err", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user