feat(launcher): implement verified atomic updates

This commit is contained in:
Erik 2026-08-14 22:09:34 +02:00
parent 2198a0cc8e
commit 2d2a5b5046
34 changed files with 6755 additions and 61 deletions

View file

@ -2,16 +2,41 @@ using System.Diagnostics;
using System.Reflection;
using AcDream.Bake;
using AcDream.Launcher.Core.Installation;
using AcDream.Launcher.Core.Updates;
using AcDream.Platform;
return args.FirstOrDefault() switch
{
"hold-install-lease" => await HoldInstallLeaseAsync(args[1..]),
"hold-update-lease" => await HoldUpdateLeaseAsync(args[1..]),
"orphan-parent" => await RunOrphanParentAsync(args[1..]),
"orphan-child" => RunOrphanChild(args[1..]),
_ => 2,
};
static async Task<int> HoldUpdateLeaseAsync(string[] arguments)
{
if (arguments.Length != 4
|| arguments[0] is not ("session" or "exclusive"))
{
return 2;
}
var barrier = new UpdateSessionBarrier(Path.GetFullPath(arguments[1]));
using IDisposable lease = arguments[0] == "session"
? barrier.AcquireSession()
: barrier.AcquireExclusive();
string readyPath = Path.GetFullPath(arguments[2]);
string releasePath = Path.GetFullPath(arguments[3]);
File.WriteAllText(readyPath, arguments[0]);
while (!File.Exists(releasePath))
{
await Task.Delay(10);
}
return 0;
}
static async Task<int> HoldInstallLeaseAsync(string[] arguments)
{
if (arguments.Length != 3)