Skip to content

Commit

Permalink
Clean up temp plugin installation folder (#936)
Browse files Browse the repository at this point in the history
* Clean up temp plugin installation folder

* Use defer
  • Loading branch information
ofalvai authored Apr 10, 2024
1 parent 52199a8 commit ddae9dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ func installLocalPlugin(pluginSourceURI, pluginLocalPth string) (Plugin, error)
}

if installedPluginVersionPtr != nil {
log.Warnf("installed plugin found with version (%s), overriding it...", (*installedPluginVersionPtr).String())
log.Warnf("installed plugin found with version %s, upgrading...", (*installedPluginVersionPtr).String())
} else {
log.Warnf("installed local plugin found, overriding it...")
log.Warnf("installed local plugin found, upgrading...")
}
}
// ---
Expand All @@ -157,6 +157,12 @@ func installLocalPlugin(pluginSourceURI, pluginLocalPth string) (Plugin, error)
if err != nil {
return Plugin{}, fmt.Errorf("failed to create tmp plugin dir, error: %s", err)
}
defer func() {
err = os.RemoveAll(tmpPluginDir)
if err != nil {
log.Warnf("Failed to clean up temp dir after plugin installation, error: %s", err)
}
}()

// Install plugin executable
executableURL := newPlugin.ExecutableURL()
Expand Down

0 comments on commit ddae9dd

Please sign in to comment.