From c6d88fe7bf963da56a05aaf1691c41893751ee86 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Sun, 30 Jun 2024 01:51:20 +0200 Subject: [PATCH] Improved version detecting --- Moonlight/Core/Services/MoonlightService.cs | 50 +++++++++---------- Moonlight/Core/UI/Views/Admin/Sys/Index.razor | 2 +- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/Moonlight/Core/Services/MoonlightService.cs b/Moonlight/Core/Services/MoonlightService.cs index 0a85bdae..7b434c1c 100644 --- a/Moonlight/Core/Services/MoonlightService.cs +++ b/Moonlight/Core/Services/MoonlightService.cs @@ -19,35 +19,31 @@ public class MoonlightService public MoonlightService() { - //TODO: Maybe extract to a method - - if (!File.Exists("version")) - { - BuildChannel = "N/A"; - BuildCommitHash = "N/A"; - BuildName = "N/A"; - BuildVersion = "N/A"; - IsDockerRun = false; - return; - } + //TODO: Maybe extract to a method to make this a bit cleaner - var line = File.ReadAllText("version"); - var parts = line.Split(";"); + if (File.Exists("version")) + { + var line = File.ReadAllText("version"); + line = line.Trim(); + + var parts = line.Split(";"); - if (parts.Length < 5) - { - BuildChannel = "N/A"; - BuildCommitHash = "N/A"; - BuildName = "N/A"; - BuildVersion = "N/A"; - IsDockerRun = false; - } - - BuildChannel = parts[0]; - BuildCommitHash = parts[1]; - BuildName = parts[2]; - BuildVersion = parts[3]; - IsDockerRun = parts[4] == "docker"; + if (parts.Length >= 5) + { + BuildChannel = parts[0]; + BuildCommitHash = parts[1]; + BuildName = parts[2]; + BuildVersion = parts[3]; + IsDockerRun = parts[4] == "docker"; + return; + } + } + + BuildChannel = "N/A"; + BuildCommitHash = "N/A"; + BuildName = "N/A"; + BuildVersion = "N/A"; + IsDockerRun = false; //TODO: Add log call } diff --git a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor index 5343daf5..ea40262c 100644 --- a/Moonlight/Core/UI/Views/Admin/Sys/Index.razor +++ b/Moonlight/Core/UI/Views/Admin/Sys/Index.razor @@ -48,7 +48,7 @@
@{ - var commitText = $"{MoonlightService.BuildCommitHash} (up-to-date)"; + var commitText = $"{MoonlightService.BuildCommitHash}"; // TODO: Add update check (possible during startup, with error handling etc) }