fix(GODT-2447): Don't assume timestamp exists in log filename

This commit is contained in:
James Houlahan 2023-03-03 10:10:06 +01:00
parent 8aec11a634
commit 53d5619c51
1 changed files with 8 additions and 1 deletions

View File

@ -144,7 +144,14 @@ func getLogName(version, revision string) string {
func getLogTime(name string) int {
re := regexp.MustCompile(`^v.*_.*_(?P<timestamp>\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
}