feat(settings): make every Settings row real; archive settings, index backups and restore
Settings (UI-01, UI-02, UI-03, UI-09, RF-4): - New Import, Analysis and Formats pages, in the order of Settings.html. Import holds the defaults of new cards (session rules, subfolders, verification, duplicates, after-import actions); Analysis the deep-analysis width cap, night and star-field thresholds and deep analysis after import or scan; Formats the decode tier of every format on this PC with a notice and Store install link per missing codec extension. - Archive gains thumbnail size and rescan interval; its templates, proxy size and thumbnail size are the open archive's own (archive.json) and new archives' defaults. - Rendering quality, parallelism and background priority now drive the jobs: quality maps to preparation size, read-ahead and default flow quality; parallelism sets the engine's workers live and caps per-job threads; background priority raises the UI thread while Titano is in front. - Advanced gains Restore (daily backups, dry-run summary, destructive confirmation, staged for the next start) and Reset all. - The naming preview's sample title is a catalog string. Engine (ENG-03, ENG-04, ENG-06): - ArchiveService.GetSettingsAsync/UpdateSettingsAsync rewrite archive.json atomically under a lease, then the index row; the server endpoint and the desktop use them, and the desktop creates archives with Settings › Archive. ThumbnailPolicy in archive.json sizes the thumbnails. - DatabaseBackups: daily VACUUM INTO copies kept x3 on the desktop and on a server on SQLite (DatabaseBackupService), staged restore checked and preceded by a fresh copy. - Maintenance vacuums the SQLite index when 10 % or more is free (dry run reports it). - JobEngine.SetWorkers; ProcessingOptions.Tune applies host tuning per job. Archive setup toasts say why in a localized sentence (RF-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
91 files changed
+2864
-357
No files matched your search
@@ -252,6 +252,65 @@ public sealed class JobEngineTests(TestContext context)
|
||||
Assert.Empty((await db.Jobs.ListAsync(null, JobKind.LightAnalyse)).Items);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheNumberOfWorkersChangesWhileTheEngineRuns()
|
||||
{
|
||||
await using var db = await OpenAsync();
|
||||
var running = 0;
|
||||
var started = 0;
|
||||
var release = new SemaphoreSlim(0);
|
||||
var handler = new CallbackHandler(JobKind.Thumbs, async c =>
|
||||
{
|
||||
Interlocked.Increment(ref running);
|
||||
Interlocked.Increment(ref started);
|
||||
try
|
||||
{
|
||||
await release.WaitAsync(c.Cancellation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Decrement(ref running);
|
||||
}
|
||||
});
|
||||
await using var engine = new JobEngine(db, [handler], new JobEngineOptions { Workers = 1, WorkerId = "pc", PollInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync();
|
||||
var jobs = new List<Job>();
|
||||
for (var i = 0; i < 6; i++) jobs.Add(await engine.EnqueueAsync(JobKind.Thumbs, []));
|
||||
|
||||
async Task UntilAsync(Func<bool> condition, string what)
|
||||
{
|
||||
var until = DateTime.UtcNow.AddSeconds(10);
|
||||
while (!condition())
|
||||
{
|
||||
Assert.True(DateTime.UtcNow < until, what);
|
||||
await Task.Delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
// One worker: one job at a time.
|
||||
await UntilAsync(() => Volatile.Read(ref running) == 1, "the first job runs");
|
||||
await Task.Delay(300);
|
||||
Assert.Equal(1, Volatile.Read(ref running));
|
||||
|
||||
// Three workers: two more jobs start at once, and no fourth.
|
||||
engine.SetWorkers(3);
|
||||
Assert.Equal(3, engine.Workers);
|
||||
await UntilAsync(() => Volatile.Read(ref running) == 3, "three jobs run together");
|
||||
await Task.Delay(300);
|
||||
Assert.Equal(3, Volatile.Read(ref running));
|
||||
|
||||
// Back to one: the running jobs finish undisturbed, then a single worker carries on.
|
||||
engine.SetWorkers(1);
|
||||
release.Release(3);
|
||||
await UntilAsync(() => Volatile.Read(ref started) == 4 && Volatile.Read(ref running) == 1, "one job after the three");
|
||||
await Task.Delay(300);
|
||||
Assert.Equal((4, 1), (Volatile.Read(ref started), Volatile.Read(ref running)));
|
||||
|
||||
release.Release(3);
|
||||
foreach (var job in jobs) await WaitForStateAsync(db, job.Id, JobState.Done, TimeSpan.FromSeconds(10));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => engine.SetWorkers(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandlerFailureMarksJobFailedWithMessage()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user