diff --git a/pkg/cleantemp/cleantemp.go b/pkg/cleantemp/cleantemp.go index 8398427fdcb5..2abc7e6807a5 100644 --- a/pkg/cleantemp/cleantemp.go +++ b/pkg/cleantemp/cleantemp.go @@ -100,13 +100,14 @@ func CleanTempArtifacts(ctx logContext.Context) error { if shouldDelete { path := filepath.Join(tempDir, entry.Name()) - if entry.IsDir() { + isDir := entry.IsDir() + if isDir { err = os.RemoveAll(path) } else { err = os.Remove(path) } if err != nil { - return fmt.Errorf("error deleting temp artifact: %s", path) + return fmt.Errorf("error deleting temp artifact (dir: %v) %s: %w", isDir, path, err) } ctx.Logger().V(4).Info("Deleted orphaned temp artifact", "artifact", path)