From 28212c9a82221b1947674d5b5557486a7077d0c5 Mon Sep 17 00:00:00 2001 From: ahrav Date: Wed, 20 Dec 2023 09:50:32 -0800 Subject: [PATCH] [chore] - lower logging level (#2249) * lower logging level * move pid len check outside loop --- pkg/cleantemp/cleantemp.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/cleantemp/cleantemp.go b/pkg/cleantemp/cleantemp.go index 2c1bbf7e9..8ff4c7d98 100644 --- a/pkg/cleantemp/cleantemp.go +++ b/pkg/cleantemp/cleantemp.go @@ -63,6 +63,11 @@ func CleanTempArtifacts(ctx logContext.Context) error { } } + if len(pids) == 0 { + ctx.Logger().V(5).Info("No trufflehog processes were found") + return nil + } + tempDir := os.TempDir() artifacts, err := os.ReadDir(tempDir) if err != nil { @@ -70,10 +75,6 @@ func CleanTempArtifacts(ctx logContext.Context) error { } for _, artifact := range artifacts { - if len(pids) == 0 { - ctx.Logger().Info("No trufflehog processes were found") - continue - } if trufflehogRE.MatchString(artifact.Name()) { // Mark these artifacts initially as ones that should be deleted. shouldDelete := true @@ -95,7 +96,7 @@ func CleanTempArtifacts(ctx logContext.Context) error { err = os.Remove(artifactPath) } if err != nil { - return fmt.Errorf("Error deleting temp artifact: %s", artifactPath) + return fmt.Errorf("error deleting temp artifact: %s", artifactPath) } ctx.Logger().Info("Deleted orphaned temp artifact", "artifact", artifactPath)