From 21875242715363e9cfb94b7686d830c4b78ee941 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 14 Mar 2024 20:45:00 +0100 Subject: [PATCH] fix: delete workdir recursively --- plugin/utils.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugin/utils.go b/plugin/utils.go index 998eafb..eb694fe 100644 --- a/plugin/utils.go +++ b/plugin/utils.go @@ -33,7 +33,9 @@ func installPackage(ctx context.Context, client *http.Client, version string, ma return fmt.Errorf("failed to create tmp dir: %w", err) } - defer os.RemoveAll(tmpdir) + defer func() { + _ = deleteDir(tmpdir) + }() log.Debug(). Str("tmpdir", tmpdir). @@ -169,9 +171,5 @@ func sanitizeArchivePath(d, t string) (string, error) { } func deleteDir(path string) error { - if _, err := os.Stat(path); os.IsNotExist(err) { - return nil - } - - return os.Remove(path) + return os.RemoveAll(path) }