From 53d5619c51cfa979c8822440328fb5b000519cfe Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Fri, 3 Mar 2023 10:10:06 +0100 Subject: [PATCH] fix(GODT-2447): Don't assume timestamp exists in log filename --- internal/logging/logging.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 90331c02..667f29c4 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -144,7 +144,14 @@ func getLogName(version, revision string) string { func getLogTime(name string) int { re := regexp.MustCompile(`^v.*_.*_(?P\d+).log$`) - timestamp, err := strconv.Atoi(re.FindStringSubmatch(name)[re.SubexpIndex("timestamp")]) + match := re.FindStringSubmatch(name) + + if len(match) == 0 { + logrus.Warn("Could not parse log name: ", name) + return 0 + } + + timestamp, err := strconv.Atoi(match[re.SubexpIndex("timestamp")]) if err != nil { return 0 }