Downloads: parallel multi-segment, sparse pre-alloc, faster SHA-256, URL auto-refresh

DownloadManager
- Parallel multi-segment download (default 8 connections, configurable up to 16)
  with per-segment Range requests. Bypasses OVH/Apache per-connection bandwidth
  throttling — typical speed-up ×4 to ×8 vs single connection.
- Reporter task on a dedicated Task with Interlocked aggregate counter (no lock
  contention with workers). Reports speed/ETA every 250ms even mid-download,
  fixes the "speed only shows at install transition" bug.
- Sparse file pre-allocation via FSCTL_SET_SPARSE before SetLength: no zero-fill,
  no SeManageVolumePrivilege, instant on any disk type. Removes 5-30s of
  preparation lag on HDD.
- HEAD probe skipped (trust manifest size, signed Ed25519). Falls back to
  single-segment if first segment returns 200 instead of 206.
- Resume URL comparison fixed: ignores HMAC querystring (?exp=&sig=) which
  changes per request, compares only host+path. Previously every resume started
  fresh because the old URL never matched the freshly signed one.
- Auto-refresh signed URL on 403/410 mid-DL: SemaphoreSlim with 5s debounce so
  8 simultaneous segment expirations trigger a single /api/download-url/ call.
  Slow-connection users (1 Mbps, 30+ hours for 14 GB) keep downloading
  transparently across multiple TTL cycles.
- Per-version hashAlgorithm:none in manifest skips client SHA-256 verification
  (still relying on Ed25519 manifest signature + HMAC URL).
- DangerButton style (red) added to Theme.xaml for the new cancel-resume action.

IntegrityService
- 16 MiB buffer (was 1 MiB), FileOptions.SequentialScan + Asynchronous,
  IncrementalHash (uses SHA-NI hardware extensions on .NET 8), double-buffering
  to overlap CPU and I/O. Typical 14 GB hash verification: 60-180s → 15-40s.

HttpClient
- MaxConnectionsPerServer=16, EnableMultipleHttp2Connections, HTTP/2 preferred,
  AutomaticDecompression=None (ZIPs are already compressed), 5min pooled
  connection lifetime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-02 19:15:27 +02:00
parent b4f205cbe5
commit 9cea07d6be
7 changed files with 667 additions and 77 deletions

View File

@@ -86,4 +86,21 @@ public sealed class DownloadDescriptor
[JsonPropertyName("sha256")]
public string Sha256 { get; set; } = string.Empty;
/// <summary>
/// Algo de vérif d'intégrité du ZIP téléchargé.
/// Valeurs : "sha256" (défaut, voir <see cref="Sha256"/>) — "none" (pas de vérif).
/// La sécurité est déjà assurée par la signature Ed25519 du manifest et HTTPS ;
/// le hash sert surtout à détecter la corruption disque/réseau sur 14 Go.
/// Pour les très gros builds où on accepte le compromis, mettre "none" évite
/// 30 s à 3 min de calcul à la fin du DL.
/// </summary>
[JsonPropertyName("hashAlgorithm")]
public string? HashAlgorithm { get; set; }
/// <summary>True si on doit vérifier le hash (sha256 non vide, non "REPLACE", algo != "none").</summary>
public bool ShouldVerifyHash =>
!string.IsNullOrEmpty(Sha256)
&& !Sha256.StartsWith("REPLACE", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(HashAlgorithm, "none", StringComparison.OrdinalIgnoreCase);
}