From 63e06cde72c48e96c735271eee7d32e6d04e5a37 Mon Sep 17 00:00:00 2001 From: Eyal Ben Moshe Date: Sun, 3 Nov 2024 13:26:07 +0200 Subject: [PATCH] Remove remaining temp file after Artifactory download (#1036) --- artifactory/services/download.go | 9 +++++---- artifactory/services/utils/searchutil.go | 10 +++++----- http/httpclient/client.go | 4 +++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/artifactory/services/download.go b/artifactory/services/download.go index a82375dd6..1fcda4817 100644 --- a/artifactory/services/download.go +++ b/artifactory/services/download.go @@ -3,10 +3,6 @@ package services import ( "errors" "fmt" - "github.com/jfrog/build-info-go/entities" - "github.com/jfrog/gofrog/crypto" - ioutils "github.com/jfrog/gofrog/io" - "github.com/jfrog/gofrog/version" "net/http" "os" "path" @@ -14,6 +10,11 @@ import ( "sort" "strings" + "github.com/jfrog/build-info-go/entities" + "github.com/jfrog/gofrog/crypto" + ioutils "github.com/jfrog/gofrog/io" + "github.com/jfrog/gofrog/version" + "github.com/jfrog/jfrog-client-go/http/httpclient" "github.com/jfrog/gofrog/parallel" diff --git a/artifactory/services/utils/searchutil.go b/artifactory/services/utils/searchutil.go index f2df3c60e..2e4e232b8 100644 --- a/artifactory/services/utils/searchutil.go +++ b/artifactory/services/utils/searchutil.go @@ -242,10 +242,9 @@ func FilterResultsByBuild(specFile *CommonParams, flags CommonConf, requiredArti // AND // 2. Properties weren't fetched during 'build' filtering // Otherwise, nil will be returned -func fetchProps(specFile *CommonParams, flags CommonConf, requiredArtifactProps RequiredArtifactProps, reader *content.ContentReader) (*content.ContentReader, error) { +func fetchProps(specFile *CommonParams, flags CommonConf, requiredArtifactProps RequiredArtifactProps, reader *content.ContentReader) (r *content.ContentReader, err error) { if !includePropertiesInAqlForSpec(specFile) && specFile.Build == "" && requiredArtifactProps != NONE { var readerWithProps *content.ContentReader - var err error switch requiredArtifactProps { case ALL: readerWithProps, err = searchProps(specFile.Aql.ItemsFind, "*", []string{"*"}, flags) @@ -253,14 +252,15 @@ func fetchProps(specFile *CommonParams, flags CommonConf, requiredArtifactProps readerWithProps, err = searchProps(specFile.Aql.ItemsFind, "symlink.dest", []string{"*"}, flags) } if err != nil { - return nil, err + return } defer func() { err = errors.Join(err, errorutils.CheckError(reader.Close())) + err = errors.Join(err, errorutils.CheckError(readerWithProps.Close())) }() - return loadMissingProperties(reader, readerWithProps) + r, err = loadMissingProperties(reader, readerWithProps) } - return nil, nil + return } func aqlSearch(aqlQuery string, flags CommonConf) (*content.ContentReader, error) { diff --git a/http/httpclient/client.go b/http/httpclient/client.go index e1157cff7..bc829797e 100644 --- a/http/httpclient/client.go +++ b/http/httpclient/client.go @@ -3,8 +3,10 @@ package httpclient import ( "bytes" "context" - "github.com/minio/sha256-simd" "strings" + + "github.com/minio/sha256-simd" + //#nosec G505 -- sha1 is supported by Artifactory. "crypto/sha1" "encoding/hex"