Skip to content

Commit

Permalink
1.0 Beta 8 (hotfix 1): Fix crash during background update check
Browse files Browse the repository at this point in the history
- Fix potential bug preventing automatically updating from a beta/RC to a full release
  • Loading branch information
Sparronator9999 committed Jan 17, 2025
1 parent 73d2350 commit 6518d37
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion YAMDCC.Common/CommonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class CommonConfig
/// to pre-releases, otherwise <see langword="false"/>.
/// </summary>
[XmlElement]
public bool PreRelease { get; set; } = true;
public bool PreRelease { get; set; }

public static string GetLastConf()
{
Expand Down
5 changes: 3 additions & 2 deletions YAMDCC.Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ public static Version GetVersion(string verString)
// expected version format: X.Y.Z-SUFFIX[.W]+REVISION,
switch (suffix)
{
// releases: X.Y.Z
// releases: X.Y.Z.250
// (ensures that beta/RC versions get updated to releases)
case "release":
verString = verString.Remove(verString.IndexOf('-'));
verString = $"{verString.Remove(verString.IndexOf('-'))}.250";
break;
// dev versions: X.Y.Z.255
// (ensures that dev versions don't get updated)
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Common/YAMDCC.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC common code library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Config/YAMDCC.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC config library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ConfigEditor/YAMDCC.ConfigEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Title>YAMDCC configuration utility</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ECAccess/YAMDCC.ECAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC EC access library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.ECInspector/YAMDCC.ECInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Title>YAMDCC EC inspector</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Logs/YAMDCC.Logs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC logging library</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Service/YAMDCC.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TargetFramework>net48</TargetFramework>
<Title>YAMDCC helper service</Title>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down
14 changes: 13 additions & 1 deletion YAMDCC.Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,19 @@ private static bool BGUpdate(bool autoUpdate)
{
try
{
Release release = Updater.GetLatestReleaseAsync(CommonConfig.GetPreRelease()).GetAwaiter().GetResult();
bool preRelease = CommonConfig.GetPreRelease();
Release release = Updater.GetLatestReleaseAsync(preRelease).GetAwaiter().GetResult();

if (release is null && !preRelease)
{
// there's no non-prerelease version yet, try to get latest pre-release
release = Updater.GetLatestReleaseAsync(true).GetAwaiter().GetResult();
if (release is null)
{
Utils.ShowError("Failed to get latest YAMDCC release info!");
return false;
}
}

if (Utils.GetCurrentVersion() < Utils.GetVersion(release.TagName.Remove(0, 1)))
{
Expand Down
7 changes: 6 additions & 1 deletion YAMDCC.Updater/UpdateForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void tsiAutoUpdate_Click(object sender, EventArgs e)

private void tsiPreRelease_Click(object sender, EventArgs e)
{
if (SetAdminSetting("setprerelease", tsiPreRelease.Checked))
if (SetAdminSetting("setprerelease", !tsiPreRelease.Checked))
{
tsiPreRelease.Checked = !tsiPreRelease.Checked;
if (btnUpdate.Tag is null)
Expand All @@ -212,6 +212,11 @@ private async void CheckUpdate()
try
{
Release = await Updater.GetLatestReleaseAsync(tsiPreRelease.Checked);
if (Release is null && !tsiPreRelease.Checked)
{
// there's no non-prerelease version yet, try to get latest pre-release
Release = await Updater.GetLatestReleaseAsync(true);
}
}
catch (HttpRequestException ex)
{
Expand Down
2 changes: 1 addition & 1 deletion YAMDCC.Updater/YAMDCC.Updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Title>YAMDCC configuration utility</Title>
<UseWindowsForms>true</UseWindowsForms>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>beta.8</VersionSuffix>
<VersionSuffix>beta.8-hotfix.1</VersionSuffix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>none</DebugType>
Expand Down

0 comments on commit 6518d37

Please sign in to comment.