Skip to content

Commit

Permalink
Added additional logging
Browse files Browse the repository at this point in the history
TechieGuy12 committed Oct 31, 2022
1 parent c2230d3 commit 29c46f5
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Plex/MediaServer.cs
Original file line number Diff line number Diff line change
@@ -366,19 +366,33 @@ private Version GetVersionFromFile(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
{
OnMessageChanged($"Couldn't get the file version. The file '{filePath}' was not found.");
return default;
}

try
{
FileVersionInfo version =
FileVersionInfo.GetVersionInfo(filePath);
if (string.IsNullOrEmpty(version.FileVersion))
{
OnMessageChanged($"The version for file '{filePath}' could not be retrieved.");
return default;
}

Version.TryParse(version.FileVersion, out Version convertedVersion);
return convertedVersion;
if (Version.TryParse(version.FileVersion, out Version convertedVersion))
{
return convertedVersion;
}
else
{
OnMessageChanged($"The version for '{filePath}' is '{version.FileVersion}, which could not be parsed.");
return default;
}
}
catch (FileNotFoundException)
{
OnMessageChanged($"Couldn't get the file version. The file '{filePath}' was not found.");
return default;
}
}
@@ -862,6 +876,17 @@ public bool IsRunning()
/// </returns>
public bool IsUpdateAvailable()
{
if (CurrentVersion == null || CurrentVersion == default)
{
OnMessageChanged($"Could not check if update is available. The installed Plex version could not be determined.");
return false;
}

if (LatestVersion == null || LatestVersion == default)
{
OnMessageChanged($"Could not check if update is available. The latest version of Plex could not be determined.");
return false;
}
return (CurrentVersion.CompareTo(LatestVersion) < 0);
}

0 comments on commit 29c46f5

Please sign in to comment.