enable nullables
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -6,7 +6,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
{
|
||||
// E v e n t s
|
||||
|
||||
public event UpdateClientStatusChangedEventHandler OnStatusChanged;
|
||||
public event UpdateClientStatusChangedEventHandler? OnStatusChanged;
|
||||
|
||||
// F i e l d s
|
||||
|
||||
@@ -18,8 +18,8 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
public string UpdateUrl { get; private set; } = updateUrl;
|
||||
public AppVersion CurrentVersion { get; private set; } = currentVersion;
|
||||
public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
|
||||
public UpdateInfo UpdateInfo { get; private set; } = null;
|
||||
public UpdatePackageInfo UpdatePackageInfo { get; private set; } = null;
|
||||
public UpdateInfo? UpdateInfo { get; private set; }
|
||||
public UpdatePackageInfo? UpdatePackageInfo { get; private set; }
|
||||
public string HostApplicationPath { get; set; } = string.Empty;
|
||||
public string ApplicationName { get; set; } = string.Empty;
|
||||
public bool InstallAsAdmin { get; set; } = false;
|
||||
@@ -51,7 +51,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
{
|
||||
var latestVersion = await CheckForUpdate();
|
||||
|
||||
if (HasUpdates)
|
||||
if (HasUpdates && latestVersion is not null)
|
||||
await UpdateInteractive(latestVersion);
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
|
||||
// F e a t u r e s
|
||||
|
||||
public async Task<UpdateInfo> GetUpdateInfo()
|
||||
public async Task<UpdateInfo?> GetUpdateInfo()
|
||||
{
|
||||
string str = await WebClient.GetStringAsync(UpdateUrl);
|
||||
var info = UpdateInfo.Parse(str);
|
||||
return info;
|
||||
}
|
||||
|
||||
private async Task<UpdatePackageInfo> CheckForUpdate()
|
||||
private async Task<UpdatePackageInfo?> CheckForUpdate()
|
||||
{
|
||||
RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PreEvent);
|
||||
|
||||
@@ -82,29 +82,26 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
return CheckForUpdate(UpdateInfo);
|
||||
}
|
||||
|
||||
private UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo)
|
||||
private UpdatePackageInfo? CheckForUpdate(UpdateInfo updateInfo)
|
||||
{
|
||||
UpdatePackageInfo foundPkgInfo = null;
|
||||
var latestVersion = CurrentVersion;
|
||||
|
||||
foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages)
|
||||
{
|
||||
if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion)
|
||||
{
|
||||
foundPkgInfo = pkgInfo;
|
||||
UpdatePackageInfo = pkgInfo;
|
||||
latestVersion = pkgInfo.Version;
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePackageInfo = foundPkgInfo;
|
||||
|
||||
if (!RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PostEvent, true))
|
||||
{
|
||||
UpdatePackageInfo = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
return foundPkgInfo;
|
||||
return UpdatePackageInfo;
|
||||
}
|
||||
|
||||
public async Task<bool> DownloadPackageAsync(UpdatePackageInfo package)
|
||||
@@ -171,7 +168,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
||||
var dataPathDir = new DirectoryInfo(dataPath);
|
||||
var destDir = new DirectoryInfo(HostApplicationPath);
|
||||
General.CopyFiles(dataPathDir, destDir);
|
||||
Utils.CopyFiles(dataPathDir, destDir);
|
||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
||||
|
||||
// Delete Package
|
||||
|
||||
Reference in New Issue
Block a user