Files
poli0981andClaude Opus 5.5 544a6c6202 fix(update): the channel follows the running copy, no update is applied at start behind FR-12, and the apply waits for a game still holding the Overlay (beta.14 PR-3, D47) (#265)
Owner request 2026-10-05: audit the update logic (no failure reported). Read against Velopack 1.2.0
and the owner's own updater log.

- update.channel defaulted to stable while every release is a GitHub pre-release: a copy left on its
  defaults never found one (the log: "No releases found" since the ledger reset). Owner decision D47:
  default `auto` (choices auto/stable/beta) - UpdateChannelPolicy: a pre-release copy asks for
  pre-releases, a release for releases; a stored stable/beta wins. Settings lists "Automatic (Beta)".
- VelopackApp applied a downloaded package at the next start (SetAutoApplyOnStartup is ON by default)
  inside Run(), before FR-12 and the Agent's stop - the log shows the Agent killed. Off now; the
  package is adopted at start (UpdateService.AdoptPending over UpdateManager.UpdatePendingRestart, no
  feed request) and goes Ready/Deferred like any other.
- OnBeforeUpdateFastCallback asks the Agent to stop before Velopack replaces the version (installer
  over an installed copy); Velopack's diagnostics go to the App's log (VelopackSerilogLogger).
- The apply waits while a game still has FrameLedger.Overlay.dll (or the Vulkan layer) loaded from the
  install folder (PayloadInUse: a mapped image refuses an exclusive write; no process opened), and
  while an Agent waits on the administrator prompt (ElevationMarker, beside the instance lock).
- Stop budget = IpcProtocol.AgentShutdownGrace (15 s, the Agent's host reads it too) + 5 s; was 10 s.
- The offer states the delta's size (UpdateInfo.DeltasToTarget) with the full package as fallback.
- IOException is Offline only from the network (HttpIOException, a socket error); the uninstaller
  removes the "Start FrameLedger with Windows" Run value.

Tests: UpdateChannelPolicyTests, UpdateServiceTests (pre-release copy asks for pre-releases; a stable
choice wins; a pending package is Ready without a feed request and applies; deferred under a session;
a held Overlay keeps it Ready, leaves the Agent alone and says why; the elevation marker holds the
folder; the stop budget outlasts the grace), VelopackHooksTests (private fields of the pinned 1.2.0
builder: _autoApply false, the logger, the before-update hook), UpdatePromptsTests, PayloadInUseTests,
UpdateFailureMapperTests, UninstallHookTests, SettingsViewModelTests, SettingsRegistryTests.
Strings en/vi/ja (ja marked review).

Docs: 11_UPDATER (the update audit, beta.14), 06_DATA_MODEL, 08_UI, 12_BUILD, LIMITATIONS,
guide/01-install, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 01:46:24 +07:00

59 lines
2.1 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FrameLedger.App.Update;
namespace FrameLedger.App.Tests.Update;
/// <summary>An <see cref="IUpdateClient"/> a test scripts: what the next check finds, what each step throws, and what was asked of it.</summary>
internal sealed class FakeUpdateClient : IUpdateClient
{
public bool IsInstalled { get; set; } = true;
public string? CurrentVersion { get; set; } = "0.1.0";
/// <summary>A package an earlier run left downloaded (beta.14), or null.</summary>
public UpdateCandidate? Pending { get; set; }
/// <summary>What the next check returns; null is "current".</summary>
public UpdateCandidate? Next { get; set; }
public UpdateException? CheckThrows { get; set; }
/// <summary>One failure per download attempt, in order; an empty queue downloads.</summary>
public Queue<UpdateException> DownloadThrows { get; } = new();
public int DownloadAttempts { get; private set; }
/// <summary>The <c>includePrereleases</c> flag of every check, in order.</summary>
public List<bool> Checks { get; } = [];
public List<string> Downloaded { get; } = [];
public List<string> Applied { get; } = [];
public UpdateCandidate? FindPendingRestart() => Pending;
public Task<UpdateCandidate?> CheckAsync(bool includePrereleases, CancellationToken ct = default)
{
Checks.Add(includePrereleases);
return CheckThrows is { } ex ? Task.FromException<UpdateCandidate?>(ex) : Task.FromResult(Next);
}
public Task DownloadAsync(UpdateCandidate candidate, IProgress<int>? progress, CancellationToken ct = default)
{
DownloadAttempts++;
if (DownloadThrows.TryDequeue(out UpdateException? ex))
{
return Task.FromException(ex);
}
progress?.Report(50);
progress?.Report(100);
Downloaded.Add(candidate.Version);
return Task.CompletedTask;
}
public void ApplyOnExit(UpdateCandidate candidate) => Applied.Add(candidate.Version);
}