feat(launcher): implement verified atomic updates
This commit is contained in:
parent
2198a0cc8e
commit
2d2a5b5046
34 changed files with 6755 additions and 61 deletions
37
src/AcDream.Launcher.Core/Updates/ReleaseManifest.cs
Normal file
37
src/AcDream.Launcher.Core/Updates/ReleaseManifest.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
namespace AcDream.Launcher.Core.Updates;
|
||||
|
||||
public sealed record ReleaseArtifact(Uri Url, string Sha256, long Size);
|
||||
|
||||
public sealed record ReleaseManifest(
|
||||
LauncherVersion Version,
|
||||
LauncherVersion MinimumLauncherVersion,
|
||||
IReadOnlyDictionary<string, ReleaseArtifact> Clients,
|
||||
IReadOnlyDictionary<string, ReleaseArtifact> Launchers)
|
||||
{
|
||||
public const int CurrentSchemaVersion = 1;
|
||||
|
||||
public ReleaseArtifact RequireClient(string rid) =>
|
||||
Clients.TryGetValue(rid, out ReleaseArtifact? artifact)
|
||||
? artifact
|
||||
: throw new LauncherUpdateException(
|
||||
$"Release {Version} has no client payload for RID '{rid}'.");
|
||||
|
||||
public ReleaseArtifact RequireLauncher(string rid) =>
|
||||
Launchers.TryGetValue(rid, out ReleaseArtifact? artifact)
|
||||
? artifact
|
||||
: throw new LauncherUpdateException(
|
||||
$"Release {Version} has no launcher payload for RID '{rid}'.");
|
||||
}
|
||||
|
||||
public sealed class LauncherUpdateException : Exception
|
||||
{
|
||||
public LauncherUpdateException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public LauncherUpdateException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue