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
@@ -129,4 +129,39 @@ public sealed class AdminTests(TestContext context)
|
||||
using var stats = await admin.GetAsync("/api/v1/archive/stats");
|
||||
await stats.ExpectAsync(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ArchiveSettingsAreWrittenToArchiveJsonAndSurviveARestart()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var admin = await server.AdminAsync();
|
||||
using var read = await admin.GetAsync("/api/v1/archive/settings");
|
||||
var archive = await read.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
|
||||
var changed = archive with { Name = "Studio", FolderTemplate = "{year}/{camera}", FileTemplate = "{name}", ProxyLongEdge = -1 };
|
||||
using (var put = await admin.PutAsJsonAsync("/api/v1/archive/settings", changed, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
await put.ExpectAsync(HttpStatusCode.OK);
|
||||
|
||||
// archive.json is the truth (BRIEF §7): the proxy jobs read it, and the next start registers the archive from it.
|
||||
var manifest = Titano.Core.Archiving.ManifestStore.ReadArchive(new Titano.Core.Archiving.ArchivePaths(server.Options.ArchivePath).ManifestPath);
|
||||
Assert.Equal(("Studio", "{year}/{camera}", "{name}", -1), (manifest.Name, manifest.LayoutTemplates.Folder, manifest.LayoutTemplates.File, manifest.ProxyPolicy.LongEdge));
|
||||
var restarted = await Titano.Server.Storage.ServerArchive.OpenAsync(server.Database, server.Options, context.Cancellation);
|
||||
Assert.Equal(("Studio", "{name}", -1), (restarted.Current.Name, restarted.Current.FileTemplate, restarted.Current.ProxyLongEdge));
|
||||
using var again = await admin.GetAsync("/api/v1/archive/settings");
|
||||
Assert.Equal(changed, await again.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto));
|
||||
|
||||
// The archive drive is gone: nothing is written and the admin hears why.
|
||||
var path = new Titano.Core.Archiving.ArchivePaths(server.Options.ArchivePath).ManifestPath;
|
||||
File.Move(path, path + ".away");
|
||||
try
|
||||
{
|
||||
using var offline = await admin.PutAsJsonAsync("/api/v1/archive/settings", changed with { ProxyLongEdge = 1280 }, ProtocolJson.Default.ArchiveSettingsDto);
|
||||
await offline.ExpectErrorAsync(HttpStatusCode.ServiceUnavailable, "archive_offline");
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Move(path + ".away", path);
|
||||
}
|
||||
Assert.Equal(-1, Titano.Core.Archiving.ManifestStore.ReadArchive(path).ProxyPolicy.LongEdge);
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,25 @@ public sealed class ArchiveModuleTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AServerOnSqliteBacksUpItsIndexOnStart()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var backups = Path.Combine(server.Options.DataPath, "backups");
|
||||
|
||||
// No copy yet, so the first one is made at once (BRIEF §6.2), named after the index it copies.
|
||||
var until = DateTime.UtcNow + TimeSpan.FromSeconds(30);
|
||||
while (!Directory.Exists(backups) || Directory.GetFiles(backups, "*.db").Length == 0)
|
||||
{
|
||||
Assert.True(DateTime.UtcNow < until, "no backup of the index");
|
||||
await Task.Delay(50);
|
||||
}
|
||||
var path = Assert.NotNull(((Titano.Data.Sqlite.SqliteDatabase)server.Database.Database).Path);
|
||||
var backup = Titano.Data.DatabaseBackups.List(backups, path).Single();
|
||||
var summary = await Titano.Data.DatabaseBackups.SummarizeBackupAsync(backup.Path, context.CreateTempDirectory("scratch"), context.Cancellation);
|
||||
Assert.Equal(server.Database.SchemaVersion, summary.SchemaVersion);
|
||||
}
|
||||
|
||||
private static byte[] Photo()
|
||||
{
|
||||
const int width = 96, height = 64;
|
||||
|
||||
Reference in new issue
Block a user