0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-11-24 13:20:39 +00:00

fix: delete workdir recursively

This commit is contained in:
Robert Kaussow 2024-03-14 20:45:00 +01:00
parent 4b5f3e55ad
commit 2187524271
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0

View File

@ -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) return fmt.Errorf("failed to create tmp dir: %w", err)
} }
defer os.RemoveAll(tmpdir) defer func() {
_ = deleteDir(tmpdir)
}()
log.Debug(). log.Debug().
Str("tmpdir", tmpdir). Str("tmpdir", tmpdir).
@ -169,9 +171,5 @@ func sanitizeArchivePath(d, t string) (string, error) {
} }
func deleteDir(path string) error { func deleteDir(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) { return os.RemoveAll(path)
return nil
}
return os.Remove(path)
} }