mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 11:02:55 +08:00
Plugins: Simplify plugin file removal (#66115)
* make explicit class check when attempting to remove plugin * simplify plugin file tracking * fix test * apply feedback * fix linter
This commit is contained in:
@ -82,6 +82,17 @@ func (f LocalFS) Files() []string {
|
||||
return files
|
||||
}
|
||||
|
||||
func (f LocalFS) Remove() error {
|
||||
// extra security check to ensure we only remove a directory that looks like a plugin
|
||||
if _, err := os.Stat(filepath.Join(f.basePath, "plugin.json")); os.IsNotExist(err) {
|
||||
if _, err = os.Stat(filepath.Join(f.basePath, "dist/plugin.json")); os.IsNotExist(err) {
|
||||
return ErrUninstallInvalidPluginDir
|
||||
}
|
||||
}
|
||||
|
||||
return os.RemoveAll(f.basePath)
|
||||
}
|
||||
|
||||
var _ fs.File = (*LocalFile)(nil)
|
||||
|
||||
// LocalFile implements a fs.File for accessing the local filesystem.
|
||||
|
Reference in New Issue
Block a user