Fixed application lockup when writing logs on close
Some checks failed
EllieBotDevs/EllieHub/pipeline/head There was a failure building this commit
Some checks failed
EllieBotDevs/EllieHub/pipeline/head There was a failure building this commit
This commit is contained in:
parent
f5c48cd8c4
commit
4deaa828c5
2 changed files with 18 additions and 10 deletions
|
@ -158,13 +158,22 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override void OnClosed(EventArgs eventArgs)
|
protected override async void OnClosed(EventArgs eventArgs)
|
||||||
{
|
{
|
||||||
// When the updater is closed, kill all bots and write their logs.
|
try
|
||||||
_botOrchestrator.StopAllBots();
|
{
|
||||||
_logWriter.FlushAllAsync(true).Wait();
|
// When the updater is closed, kill all bots and write their logs.
|
||||||
|
_botOrchestrator.StopAllBots();
|
||||||
base.OnClosed(eventArgs);
|
_logWriter.FlushAllAsync(true).Wait();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
base.OnClosed(eventArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -256,7 +265,6 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
||||||
|
|
||||||
_ = new UpdateView().ShowDialog(this);
|
_ = new UpdateView().ShowDialog(this);
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _appResolver.InstallOrUpdateAsync(AppContext.BaseDirectory);
|
await _appResolver.InstallOrUpdateAsync(AppContext.BaseDirectory);
|
||||||
|
@ -276,13 +284,13 @@ public partial class AppView : ReactiveWindow<AppViewModel>
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
private async Task MigrateOldBotsAsync()
|
private async Task MigrateOldBotsAsync()
|
||||||
{
|
{
|
||||||
var configFileUri = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieBotUpdater", "bots.json");
|
var configFileUri = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "EllieBotUpdater", "bots.json");
|
||||||
|
|
||||||
if (File.Exists(AppStatics.AppConfigUri) || !File.Exists(configFileUri))
|
if (File.Exists(AppStatics.AppConfigUri) || !File.Exists(configFileUri))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var bots = (JsonSerializer.Deserialize<OldUpdaterBotEntry[]>(await File.ReadAllTextAsync(configFileUri)) ?? [])
|
var bots = (JsonSerializer.Deserialize<OldUpdaterBotEntry[]>(await File.ReadAllTextAsync(configFileUri)) ?? [])
|
||||||
.Where(x => !string.IsNullOrWhiteSpace(x.PathUri) && File.Exists(Path.Combine(x.PathUri, "EllieBot.exe")))
|
.Where(x => !string.IsNullOrWhiteSpace(x.PathUri) && File.Exists(Path.Join(x.PathUri, "EllieBot.exe")))
|
||||||
.Select((x, y) => new BotEntry(x.Guid, new(x.Name, x.PathUri!, (uint)y, x.Version, x.IconUri)));
|
.Select((x, y) => new BotEntry(x.Guid, new(x.Name, x.PathUri!, (uint)y, x.Version, x.IconUri)));
|
||||||
|
|
||||||
foreach (var botEntry in bots)
|
foreach (var botEntry in bots)
|
||||||
|
|
|
@ -159,7 +159,7 @@ public sealed class AppResolver : IAppResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the new binary file as executable.
|
// Mark the new binary file as executable.c
|
||||||
if (Environment.OSVersion.Platform is PlatformID.Unix)
|
if (Environment.OSVersion.Platform is PlatformID.Unix)
|
||||||
{
|
{
|
||||||
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", BinaryUri]);
|
using var chmod = ToastieUtilities.StartProcess("chmod", ["+x", BinaryUri]);
|
||||||
|
|
Loading…
Reference in a new issue