AI-Studio/app/MindWork AI Studio/Tools/Services/RustService.Updates.cs
Thorsten Sommer 519abe4fc2
Some checks are pending
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Fixed changelog encoding & prepared re-release v26.4.1 (#745)
2026-04-17 19:30:13 +02:00

58 lines
1.9 KiB
C#

using AIStudio.Tools.Rust;
namespace AIStudio.Tools.Services;
public sealed partial class RustService
{
public async Task<UpdateResponse> CheckForUpdate()
{
try
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(45));
var response = await this.http.GetFromJsonAsync<UpdateResponse>("/updates/check", this.jsonRustSerializerOptions, cts.Token);
if (response == default)
{
this.logger!.LogError("Failed to check for an update: the Rust endpoint returned an empty response.");
return new UpdateResponse
{
Error = true,
UpdateIsAvailable = false,
NewVersion = string.Empty,
Changelog = string.Empty
};
}
if (response.Error)
this.logger!.LogWarning("The Rust updater reported an error while checking for updates.");
this.logger!.LogInformation($"Checked for an update: update available='{response.UpdateIsAvailable}'; error='{response.Error}'; next version='{response.NewVersion}'; changelog len='{response.Changelog.Length}'");
return response;
}
catch (Exception e)
{
this.logger!.LogError(e, "Failed to check for an update.");
return new UpdateResponse
{
Error = true,
UpdateIsAvailable = false,
NewVersion = string.Empty,
Changelog = string.Empty
};
}
}
public async Task InstallUpdate()
{
try
{
var cts = new CancellationTokenSource();
await this.http.GetAsync("/updates/install", cts.Token);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}