Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
chore: rename downloaded file (#1149) (#1150)
Browse files Browse the repository at this point in the history
(cherry picked from commit fd419f4)

Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
  • Loading branch information
mergify[bot] and mdelapenya authored May 6, 2021
1 parent 503d69e commit 998d8ca
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,20 @@ func FetchBeatsBinary(artifactName string, artifact string, version string, fall
return filePath, err
}

binariesCache[URL] = filePath
// use artifact name as file name to avoid having URL params in the name
sanitizedFilePath := path.Join(path.Dir(filePath), artifactName)
err = os.Rename(filePath, sanitizedFilePath)
if err != nil {
log.WithFields(log.Fields{
"fileName": filePath,
"sanitizedFileName": sanitizedFilePath,
}).Warn("Could not sanitize downloaded file name. Keeping old name")
sanitizedFilePath = filePath
}

binariesCache[URL] = sanitizedFilePath

return filePath, nil
return sanitizedFilePath, nil
}

var downloadURL string
Expand Down

0 comments on commit 998d8ca

Please sign in to comment.