Plugins: Remove pre-existing plugin installs when installing with grafana-cli (#31515)

* remove old install before install if exists

* fix log format
This commit is contained in:
Will Browne 2021-03-10 19:13:08 +01:00 committed by GitHub
parent a55a272276
commit c40d96d0ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,6 +230,16 @@ func extractFiles(archiveFile string, pluginName string, dstDir string, allowSym
}
logger.Debugf("Extracting archive %q to %q...\n", archiveFile, dstDir)
existingInstallDir := filepath.Join(dstDir, pluginName)
if _, err := os.Stat(existingInstallDir); !os.IsNotExist(err) {
err = os.RemoveAll(existingInstallDir)
if err != nil {
return err
}
logger.Infof("Removed existing installation of %s\n\n", pluginName)
}
r, err := zip.OpenReader(archiveFile)
if err != nil {
return err