fix(launcher): harden updater crash recovery
This commit is contained in:
parent
2d2a5b5046
commit
1955ca8ab5
27 changed files with 2714 additions and 544 deletions
|
|
@ -177,6 +177,61 @@ public sealed class ClientVersionStoreTests : IDisposable
|
|||
Path.Combine(resolution.Directory!, "AcDream.App" + ExecutableSuffix)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LinuxTreatsNonCanonicalInstallJsonCasingAsUnrecordedContent()
|
||||
{
|
||||
if (!OperatingSystem.IsLinux())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var store = new ClientVersionStore(_paths);
|
||||
ClientVersionResolution installed = await PromoteAsync(store, "1.0.0", "linux-case");
|
||||
await File.WriteAllTextAsync(
|
||||
Path.Combine(installed.Directory!, "INSTALL.JSON"),
|
||||
"must-not-be-hidden");
|
||||
|
||||
ClientVersionResolution resolution = await new ClientVersionStore(_paths)
|
||||
.LoadAndRecoverAsync(_rid);
|
||||
|
||||
Assert.Equal(ClientVersionState.Invalid, resolution.State);
|
||||
Assert.Contains("unrecorded", resolution.Status, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExclusiveStartupReclaimsOnlyCanonicalGuidOwnedResidue()
|
||||
{
|
||||
var store = new ClientVersionStore(_paths);
|
||||
Directory.CreateDirectory(store.AppDirectory);
|
||||
string id = Guid.NewGuid().ToString("N");
|
||||
string nearId = id[..31] + "g";
|
||||
string exactStaging = Path.Combine(store.AppDirectory, ".client-staging-" + id);
|
||||
string exactCorrupt = Path.Combine(store.AppDirectory, ".client-corrupt-" + id);
|
||||
string exactDownload = Path.Combine(
|
||||
store.AppDirectory,
|
||||
".client-download-" + id + ".zip");
|
||||
string nearStaging = exactStaging + "-user";
|
||||
string nearCorrupt = Path.Combine(store.AppDirectory, ".client-corrupt-" + nearId);
|
||||
string nearDownload = Path.Combine(
|
||||
store.AppDirectory,
|
||||
".client-download-" + id + ".zip.user");
|
||||
Directory.CreateDirectory(exactStaging);
|
||||
Directory.CreateDirectory(exactCorrupt);
|
||||
Directory.CreateDirectory(nearStaging);
|
||||
Directory.CreateDirectory(nearCorrupt);
|
||||
await File.WriteAllTextAsync(exactDownload, "owned");
|
||||
await File.WriteAllTextAsync(nearDownload, "preserve");
|
||||
|
||||
_ = await store.LoadAndRecoverAsync(_rid);
|
||||
|
||||
Assert.False(Directory.Exists(exactStaging));
|
||||
Assert.False(Directory.Exists(exactCorrupt));
|
||||
Assert.False(File.Exists(exactDownload));
|
||||
Assert.True(Directory.Exists(nearStaging));
|
||||
Assert.True(Directory.Exists(nearCorrupt));
|
||||
Assert.True(File.Exists(nearDownload));
|
||||
}
|
||||
|
||||
private string ExecutableSuffix => _rid.StartsWith("win-", StringComparison.Ordinal)
|
||||
? ".exe"
|
||||
: string.Empty;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue