Update submit.go

Refactor slightly to be clearer that we only add .gz if it's not already there.

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
Michael Kaye 2022-01-24 13:38:50 +00:00 committed by GitHub
parent 8e842a3fc2
commit ac76e5e706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -438,10 +438,9 @@ func saveLogPart(logNum int, filename string, reader io.Reader, reportDir string
// Either way, we need to append .gz, because we're compressing it.
var leafName string
if logRegexp.MatchString(filename) {
if strings.HasSuffix(filename, ".gz") {
leafName = filename
} else {
leafName = filename + ".gz"
leafName = filename
if !strings.HasSuffix(filename, ".gz") {
leafName += ".gz"
}
} else {
leafName = fmt.Sprintf("logs-%04d.log.gz", logNum)