Skip to content

Commit

Permalink
Update checker now correctly handles release candidate builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Jan 12, 2024
1 parent 474a6af commit eaa16d2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dnSpy/dnSpy/MainApp/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
using System.Diagnostics;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading.Tasks;
using dnSpy.Contracts.Settings;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -100,6 +101,7 @@ public UpdateService(ISettingsService settingsService) {
}

static readonly Version currentVersion = GetCurrentVersion();
static readonly bool isFinalRelease = GetIsFinalRelease();

static Version GetCurrentVersion() {
var currentAsm = typeof(StartUpClass).Assembly;
Expand All @@ -113,10 +115,21 @@ static Version GetCurrentVersion() {
return currentAsm.GetName().Version!;
}

static bool GetIsFinalRelease() {
var currentAsm = typeof(StartUpClass).Assembly;
try {
var infoVerAttr = currentAsm.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
return infoVerAttr.InformationalVersion is null || !infoVerAttr.InformationalVersion.Contains("-");

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (netframework)

Dereference of a possibly null reference.

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (netframework)

Dereference of a possibly null reference.

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (net-x86)

Dereference of a possibly null reference.

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (net-x86)

Dereference of a possibly null reference.

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (net-x64)

Dereference of a possibly null reference.

Check warning on line 122 in dnSpy/dnSpy/MainApp/UpdateService.cs

View workflow job for this annotation

GitHub Actions / Build (net-x64)

Dereference of a possibly null reference.
}
catch {
}
return false;
}

public async Task<UpdateCheckInfo> CheckForUpdatesAsync() {
var updateInfo = await TryGetLatestVersionAsync();
if (updateInfo is not null) {
if (updateInfo.Value.Version > currentVersion)
if (updateInfo.Value.Version > currentVersion || !isFinalRelease && updateInfo.Value.Version == currentVersion)
return new UpdateCheckInfo(true, updateInfo.Value);
return new UpdateCheckInfo(false, default);
}
Expand All @@ -140,8 +153,11 @@ public async Task<UpdateCheckInfo> CheckForUpdatesAsync() {
return null;
if (tagName[0] == 'v')
tagName = tagName.Remove(0, 1);
if (Version.TryParse(tagName, out var version))
if (Version.TryParse(tagName, out var version)) {
if (version.Revision == -1)
version = new Version(version.Major, version.Minor, version.Build, 0);
return new VersionInfo(version, htmlUrl);
}
}
catch {
}
Expand Down

0 comments on commit eaa16d2

Please sign in to comment.