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

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. // Either way, we need to append .gz, because we're compressing it.
var leafName string var leafName string
if logRegexp.MatchString(filename) { if logRegexp.MatchString(filename) {
if strings.HasSuffix(filename, ".gz") { leafName = filename
leafName = filename if !strings.HasSuffix(filename, ".gz") {
} else { leafName += ".gz"
leafName = filename + ".gz"
} }
} else { } else {
leafName = fmt.Sprintf("logs-%04d.log.gz", logNum) leafName = fmt.Sprintf("logs-%04d.log.gz", logNum)