mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-05-19 22:52:15 +00:00
Improved update service with error handling and logging
This commit is contained in:
parent
1e484a02a3
commit
c6ed7e3c0c
@ -7513,6 +7513,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::RUSTSERVICE::T4007657575"] = "Failed
|
|||||||
-- No update found.
|
-- No update found.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "No update found."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "No update found."
|
||||||
|
|
||||||
|
-- Failed to check for updates. Please try again later.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1064148123"] = "Failed to check for updates. Please try again later."
|
||||||
|
|
||||||
-- Failed to install update automatically. Please try again manually.
|
-- Failed to install update automatically. Please try again manually.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Failed to install update automatically. Please try again manually."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Failed to install update automatically. Please try again manually."
|
||||||
|
|
||||||
|
|||||||
@ -7515,6 +7515,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::RUSTSERVICE::T4007657575"] = "Abrufe
|
|||||||
-- No update found.
|
-- No update found.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "Kein Update gefunden."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "Kein Update gefunden."
|
||||||
|
|
||||||
|
-- Failed to check for updates. Please try again later.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1064148123"] = "Die Suche nach Updates ist fehlgeschlagen. Bitte versuchen Sie es später erneut."
|
||||||
|
|
||||||
-- Failed to install update automatically. Please try again manually.
|
-- Failed to install update automatically. Please try again manually.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Fehler bei der automatischen Installation des Updates. Bitte versuchen Sie es manuell erneut."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Fehler bei der automatischen Installation des Updates. Bitte versuchen Sie es manuell erneut."
|
||||||
|
|
||||||
|
|||||||
@ -7515,6 +7515,9 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::RUSTSERVICE::T4007657575"] = "Failed
|
|||||||
-- No update found.
|
-- No update found.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "No update found."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1015418291"] = "No update found."
|
||||||
|
|
||||||
|
-- Failed to check for updates. Please try again later.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T1064148123"] = "Failed to check for updates. Please try again later."
|
||||||
|
|
||||||
-- Failed to install update automatically. Please try again manually.
|
-- Failed to install update automatically. Please try again manually.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Failed to install update automatically. Please try again manually."
|
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SERVICES::UPDATESERVICE::T3709709946"] = "Failed to install update automatically. Please try again manually."
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,22 @@ public sealed partial class RustService
|
|||||||
{
|
{
|
||||||
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(45));
|
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(45));
|
||||||
var response = await this.http.GetFromJsonAsync<UpdateResponse>("/updates/check", this.jsonRustSerializerOptions, cts.Token);
|
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}'");
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
@ -20,6 +36,8 @@ public sealed partial class RustService
|
|||||||
{
|
{
|
||||||
Error = true,
|
Error = true,
|
||||||
UpdateIsAvailable = false,
|
UpdateIsAvailable = false,
|
||||||
|
NewVersion = string.Empty,
|
||||||
|
Changelog = string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,14 +16,16 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
|
|||||||
private readonly SettingsManager settingsManager;
|
private readonly SettingsManager settingsManager;
|
||||||
private readonly MessageBus messageBus;
|
private readonly MessageBus messageBus;
|
||||||
private readonly RustService rust;
|
private readonly RustService rust;
|
||||||
|
private readonly ILogger<UpdateService> logger;
|
||||||
|
|
||||||
private TimeSpan updateInterval;
|
private TimeSpan updateInterval;
|
||||||
|
|
||||||
public UpdateService(MessageBus messageBus, SettingsManager settingsManager, RustService rust)
|
public UpdateService(MessageBus messageBus, SettingsManager settingsManager, RustService rust, ILogger<UpdateService> logger)
|
||||||
{
|
{
|
||||||
this.settingsManager = settingsManager;
|
this.settingsManager = settingsManager;
|
||||||
this.messageBus = messageBus;
|
this.messageBus = messageBus;
|
||||||
this.rust = rust;
|
this.rust = rust;
|
||||||
|
this.logger = logger;
|
||||||
|
|
||||||
this.messageBus.RegisterComponent(this);
|
this.messageBus.RegisterComponent(this);
|
||||||
this.ApplyFilters([], [ Event.USER_SEARCH_FOR_UPDATE ]);
|
this.ApplyFilters([], [ Event.USER_SEARCH_FOR_UPDATE ]);
|
||||||
@ -113,6 +115,23 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var response = await this.rust.CheckForUpdate();
|
var response = await this.rust.CheckForUpdate();
|
||||||
|
if (response.Error)
|
||||||
|
{
|
||||||
|
this.logger.LogWarning("Update check failed. The updater did not return a usable result.");
|
||||||
|
|
||||||
|
if (notifyUserWhenNoUpdate)
|
||||||
|
{
|
||||||
|
SNACKBAR!.Add(TB("Failed to check for updates. Please try again later."), Severity.Error, config =>
|
||||||
|
{
|
||||||
|
config.Icon = Icons.Material.Filled.Error;
|
||||||
|
config.IconSize = Size.Large;
|
||||||
|
config.IconColor = Color.Error;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (response.UpdateIsAvailable)
|
if (response.UpdateIsAvailable)
|
||||||
{
|
{
|
||||||
// ReSharper disable RedundantAssignment
|
// ReSharper disable RedundantAssignment
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user