Fix error when technology couldn't be determined
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adam Štrauch 2023-09-23 23:41:00 +02:00
parent dab9b52953
commit 7f8ed1c018
Signed by: cx
GPG Key ID: 7262DAFE292BCE20

View File

@ -2,7 +2,6 @@ package containers
import (
"bytes"
"errors"
"fmt"
"log"
"os"
@ -173,7 +172,14 @@ func getTechAndVersion(symlink string) (*TechInfo, error) {
re := regexp.MustCompile(`\d+\.\d+\.\d+`)
version := re.FindString(parts[1])
if version == "" {
return nil, errors.New("failed to extract version from symlink")
// In case version couldn't be determined we return "unknown", otherwise returning
// error in this case was crashing admin when user fucked up the symlink for the
// tech manually.
log.Println("failed to extract version from symlink")
return &TechInfo{
Tech: "unknown",
Version: "",
}, nil
}
return &TechInfo{