dcb3637cca
LayoutStore.cs 1402 -> 47-line shell + 5 partials, grouped by functionality (line count is a consequence, not the goal): - LayoutStore.Migrations.cs: all DB schema migration (EnsureSchema, GetUserVersion, MigrateSourceTable/WebcamConfigTable/ToV3/SceneTable/SceneSocialBarColumn/ SocialsTable/SocialEntryTable) - LayoutStore.Load.cs: Load() scene/source read-back - LayoutStore.Save.cs: Save() full scene tree write - LayoutStore.Settings.cs: key/value settings + mic/record-folder/reusable-stream + license/transition/broadcast/hotkey/window-state GetSetting/UpsertSetting - LayoutStore.Assets.cs: GetAssetBytes/UpsertAsset blob IO - LayoutStore.cs: shell — Instance, fields, ctor, Dispose Converted to public partial class LayoutStore : IDisposable. Pruned per-file dead usings. Phase 3 DOWN: no production .cs exceeds 500 lines. Zero behavior change; build 0 warnings; 246 pass, only the 2 known failures. Docs: ViewModels/index.md Phase 3 tracker updated in same commit.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System.Security.Cryptography;
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
namespace ytLive.Services;
|
|
|
|
public partial class LayoutStore : IDisposable
|
|
{
|
|
public byte[]? GetAssetBytes(string assetId)
|
|
{
|
|
using var cmd = _connection.CreateCommand();
|
|
cmd.CommandText = "SELECT Data FROM Asset WHERE Id = $id";
|
|
cmd.Parameters.AddWithValue("$id", assetId);
|
|
return cmd.ExecuteScalar() as byte[];
|
|
}
|
|
|
|
public string UpsertAsset(byte[] data, int pixelWidth, int pixelHeight)
|
|
{
|
|
var hash = Convert.ToHexString(SHA256.HashData(data));
|
|
var id = Guid.NewGuid().ToString();
|
|
|
|
using var cmd = _connection.CreateCommand();
|
|
cmd.CommandText = """
|
|
INSERT INTO Asset (Id, Hash, Data, PixelWidth, PixelHeight)
|
|
VALUES ($id, $hash, $data, $w, $h)
|
|
ON CONFLICT(Hash) DO NOTHING;
|
|
""";
|
|
cmd.Parameters.AddWithValue("$id", id);
|
|
cmd.Parameters.AddWithValue("$hash", hash);
|
|
cmd.Parameters.AddWithValue("$data", data);
|
|
cmd.Parameters.AddWithValue("$w", pixelWidth);
|
|
cmd.Parameters.AddWithValue("$h", pixelHeight);
|
|
cmd.ExecuteNonQuery();
|
|
|
|
cmd.CommandText = "SELECT Id FROM Asset WHERE Hash = $hash;";
|
|
return (string)cmd.ExecuteScalar()!;
|
|
}
|
|
|
|
// ─── License (TASK 10 — Polar billing) ───
|
|
|
|
/// <summary>The saved license key, or null if never entered.</summary>
|
|
}
|