hostinfo: cache device model to speed up init

This was causing a relatively consistent ~10ms of delay on Linux.

Signed-off-by: Kyle Carberry <kyle@carberry.com>
This commit is contained in:
Kyle Carberry
2024-04-01 16:26:20 -04:00
committed by Brad Fitzpatrick
parent ec87e219ae
commit 27038ee3c2
2 changed files with 18 additions and 10 deletions

View File

@ -22,9 +22,7 @@ func init() {
distroName = distroNameLinux
distroVersion = distroVersionLinux
distroCodeName = distroCodeNameLinux
if v := linuxDeviceModel(); v != "" {
SetDeviceModel(v)
}
deviceModel = deviceModelLinux
}
var (
@ -50,7 +48,7 @@ func distroCodeNameLinux() string {
return lazyVersionMeta.Get().DistroCodeName
}
func linuxDeviceModel() string {
func deviceModelLinux() string {
for _, path := range []string{
// First try the Synology-specific location.
// Example: "DS916+-j"