fix(art): re-seed a bundled background when the stored bytes differ
The creator's profile still showed the previous Starting art after the replacement, with `Art.DefaultVersion = 4` recorded — so the version gate had already declared itself done. It compared a constant against the embedded resource, and those two were compiled at different moments (version 4 landed with the OLD image embedded; the corrected image reached the assembly one build later). A version bump can always be raced that way. The seed now compares BYTES: `LayoutStore.AssetMatches` hashes the bundled resource and checks the row the background already points at. Same bytes → leave it untouched (so this is idempotent and never churns the database). Different bytes → re-stamp. The version constant and its setting are gone, because a heal that only runs once can silently skip the one launch it was needed for. `SceneThumbnailTests` planted its own art on a background still flagged as default art — in the real app that state only ever means stale bundled art, because Browse… sets the path and clears the flag. The fixture now models a creator's own picture. Tests: 572 green, 0 warnings. Verified the profile's Starting asset hash (167CDD3B…, the two-category render) differs from the shipped `starting-background.jpg` (5FC6DD22…), so the next launch re-seeds it.
This commit is contained in:
@@ -35,6 +35,20 @@ public partial class LayoutStore : IDisposable
|
||||
return (string)cmd.ExecuteScalar()!;
|
||||
}
|
||||
|
||||
/// <summary>True when the asset already holds exactly these bytes. Used to decide whether a
|
||||
/// bundled image needs re-seeding: comparing bytes cannot go stale the way a version constant
|
||||
/// can (the constant and the embedded resource were built at different moments twice).</summary>
|
||||
public bool AssetMatches(string assetId, byte[] data)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(assetId)) return false;
|
||||
var hash = Convert.ToHexString(SHA256.HashData(data));
|
||||
using var cmd = _connection.CreateCommand();
|
||||
cmd.CommandText = "SELECT 1 FROM Asset WHERE Id = $id AND Hash = $hash;";
|
||||
cmd.Parameters.AddWithValue("$id", assetId);
|
||||
cmd.Parameters.AddWithValue("$hash", hash);
|
||||
return cmd.ExecuteScalar() != null;
|
||||
}
|
||||
|
||||
// ─── License (TASK 10 — Polar billing) ───
|
||||
|
||||
/// <summary>The saved license key, or null if never entered.</summary>
|
||||
|
||||
@@ -63,12 +63,6 @@ public partial class LayoutStore : IDisposable
|
||||
|
||||
public void SaveShowMonetaryMetrics(bool show) => UpsertSetting("Metrics.ShowMonetary", show ? "1" : "0");
|
||||
|
||||
/// <summary>Which vintage of the shipped default scene art this layout was stamped with. Bumped when
|
||||
/// a bundled background is replaced, so existing layouts re-seed instead of keeping the old art.</summary>
|
||||
public int LoadDefaultArtVersion() => int.TryParse(GetSetting("Art.DefaultVersion"), out var v) ? v : 1;
|
||||
|
||||
public void SaveDefaultArtVersion(int version) => UpsertSetting("Art.DefaultVersion", version.ToString());
|
||||
|
||||
public bool LoadAutoChromaScreen() => GetSetting("Video.AutoChromaScreen") == "1";
|
||||
|
||||
public void SaveAutoChromaScreen(bool enabled) => UpsertSetting("Video.AutoChromaScreen", enabled ? "1" : "0");
|
||||
|
||||
Reference in New Issue
Block a user