From 79e5fb7a67932637c80d8ffb178ebdc3aa09c5bc Mon Sep 17 00:00:00 2001 From: vbanos Date: Sun, 19 Jan 2025 13:40:32 +0100 Subject: [PATCH] Simplify GenerateWarcFileName --- utils.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utils.go b/utils.go index 433eeca..d2922fe 100644 --- a/utils.go +++ b/utils.go @@ -327,15 +327,15 @@ func GenerateWarcFileName(prefix string, compression string, atomicSerial *int64 now := time.Now().UTC() date := now.Format("20060102150405") + strconv.Itoa(now.Nanosecond())[:3] - if compression != "" { - if compression == "GZIP" { - return prefix + "-" + date + "-" + formattedSerial + "-" + hostName + ".warc.gz.open" - } - if compression == "ZSTD" { - return prefix + "-" + date + "-" + formattedSerial + "-" + hostName + ".warc.zst.open" - } + var fileExt string + if compression == "GZIP" { + fileExt = ".warc.gz.open" + } else if compression == "ZSTD" { + fileExt = ".warc.zst.open" + } else { + fileExt = ".warc.open" } - return prefix + "-" + date + "-" + formattedSerial + "-" + hostName + ".warc.open" + return prefix + "-" + date + "-" + formattedSerial + "-" + hostName + fileExt } func getContentLength(rwsc spooledtempfile.ReadWriteSeekCloser) int {