feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s

- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports.
- The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start.
- Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job.

Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 11:19:26 +01:00
1 parent 1f089888e8
commit af9eeaab9b
349 files changed
+28341 -1304

No files matched your search

+27 -29
View File
@@ -30,8 +30,8 @@ namespace Chronos.App.Sections;
/// Archive rows show and change the open archive's own settings (archive.json, through the archive engine) and are the
/// defaults of new archives; Import and Analysis feed the defaults of new cards and the analysis jobs; Rendering feeds
/// the jobs from the next one on; Formats lists the decode tier per format on this PC with the codec extensions to
/// install; Advanced restores the index from a daily backup at the next start; About, the last page, shows this copy
/// (<see cref="ShellViewModel.About"/>, whose update notice Updates shows).
/// install; Advanced sets the log files (<see cref="Logs"/>) and restores the index from a backup at the next start;
/// About, the last page, shows this copy (<see cref="ShellViewModel.About"/>, whose update notice Updates shows).
/// </summary>
public sealed class SettingsViewModel : SectionViewModel
{
@@ -73,7 +73,7 @@ public sealed class SettingsViewModel : SectionViewModel
new(SettingsPage.General, ["Settings.General.Language", "Settings.General.Theme", .. ShowsStartup ? (string[])["Settings.General.Startup"] : [],
"Settings.General.Notifications", .. ProductFeatures.AdsEnabled ? (string[])["Settings.General.Usage"] : []]),
new(SettingsPage.Archive, ["Settings.Archive.Root", "Settings.Archive.Folders", "Settings.Archive.Files", "Settings.Archive.Proxies",
"Settings.Archive.Thumbnails", "Settings.Archive.Polling"]),
"Settings.Archive.Thumbnails"]),
new(SettingsPage.Import, ["Import.Scan.Sessions", "Import.Label.Scan", "Import.Scan.Subfolders", "Import.Scan.Verify", "Import.Label.Duplicates",
"Import.Label.After", "Import.After.Eject"]),
new(SettingsPage.Analysis, ["Settings.Analysis.Width", "Settings.Analysis.Night", "Settings.Analysis.Stars", "Settings.Analysis.Deep"]),
@@ -83,8 +83,9 @@ public sealed class SettingsViewModel : SectionViewModel
new(SettingsPage.Storage, ["Settings.Storage.Folder", "Settings.Storage.Thumbnails", "Settings.Storage.Limit"]),
new(SettingsPage.Server, ["Settings.Server.Default", "Settings.Server.RenderNode", "Settings.Server.Certificates"]),
new(SettingsPage.Updates, ["Settings.General.CheckOnStart", "Settings.Updates.Latest", "About.Update.Check", "About.Releases"]),
new(SettingsPage.Advanced, ["Settings.Advanced.DataFolder", "Settings.Advanced.Logs", "Settings.Advanced.Diagnostics", "Settings.Advanced.Backup",
"Settings.Advanced.Restore", "Settings.Advanced.Reset"]),
new(SettingsPage.Advanced, ["Settings.Advanced.DataFolder", "Settings.Advanced.Logs", "Settings.Advanced.LogLevel", "Settings.Advanced.KeepLogs",
"Settings.Advanced.FileSize", "Settings.Advanced.LogsTotal", "Settings.Advanced.Rotation", "Settings.Advanced.Diagnostics",
"Settings.Advanced.DiagnosticsLogs", "Settings.Advanced.Backup", "Settings.Advanced.Restore", "Settings.Advanced.Reset"]),
// The translation row shows outside English only, and the language changes while Settings is open.
new(SettingsPage.About, () => ["Shell.AppName", "About.Build", "About.Runtime", "About.System", "About.Licence", "About.ThirdParty",
.. Shell.About.IsTranslated ? (string[])["About.Translation"] : []]),
@@ -156,6 +157,10 @@ public sealed class SettingsViewModel : SectionViewModel
}, () => Loc.L("Tooltips.Settings.Parallelism"));
JobPriorities = [.. PriorityKinds.Select(k => new JobPriorityRow(k, kind => Shell.Services.PriorityQueue.LevelOf(kind), SetJobPriority))];
// ---- Advanced ----
// Saving applies them to the log files (App.SaveSettings).
Logs = new LogSettingsRows(_s, Save);
// ---- Storage ----
CacheFolder = new EditableField(CacheStore.Folder(shell.Services.Environment, _s), v => ArchiveLocations.Validate(v), v =>
{
@@ -435,23 +440,6 @@ public sealed class SettingsViewModel : SectionViewModel
}
}
public IReadOnlyList<SettingsOption<int>> ScanIntervals =>
[.. new[] { 5, 10, 15, 30, 60 }.Select(m => new SettingsOption<int>(m, Formatting.Duration(TimeSpan.FromMinutes(m))))];
/// <summary>How often this PC rescans the open archive for changes made elsewhere (BRIEF §7: polling).</summary>
public SettingsOption<int> SelectedScanInterval
{
get => ScanIntervals.FirstOrDefault(p => p.Value == _s.ScanIntervalMinutes) ?? ScanIntervals[1];
set
{
if (value is null || value.Value == _s.ScanIntervalMinutes) return;
_s.ScanIntervalMinutes = value.Value;
// Saving applies it: the running rescan timer takes the new period.
Save();
OnPropertyChanged();
}
}
// ---------------- Import ----------------
public EditableField SessionGap { get; }
@@ -765,12 +753,16 @@ public sealed class SettingsViewModel : SectionViewModel
public string DataFolder => Shell.Services.Environment.DataDirectory;
public string LogsFolder => Shell.Services.Environment.LogDirectory;
public string PortableText => Loc.L(Shell.Services.Environment.IsPortable ? "Settings.Advanced.PortableOn" : "Settings.Advanced.PortableOff");
/// <summary>Level, retention, size limits and rotation of the log files, and the diagnostics bundle's share of each.</summary>
public LogSettingsRows Logs { get; }
public ICommand OpenDataFolderCommand { get; }
public ICommand OpenLogsCommand { get; }
public ICommand ExportDiagnosticsCommand { get; }
public ICommand BackupDatabaseCommand { get; }
/// <summary>The daily copies of the index, newest first (Restore).</summary>
/// <summary>The copies of the index in the backups folder (the Index backup schedule's, Back up now's), newest first (Restore).</summary>
public IReadOnlyList<BackupOption> Backups
{
get => _backups;
@@ -807,10 +799,10 @@ public sealed class SettingsViewModel : SectionViewModel
public ICommand ResetSectionCommand { get; }
/// <summary>
/// Advanced holds no setting with a default (paths and actions only), Formats only shows this PC and About only this
/// copy: they have no Reset section.
/// Formats only shows this PC and About only this copy: they have no Reset section. Advanced's resets its log rows
/// (owner review 2, R11); its paths and actions have no default.
/// </summary>
public bool CanResetSection => _page is not (SettingsPage.Advanced or SettingsPage.Formats or SettingsPage.About);
public bool CanResetSection => _page is not (SettingsPage.Formats or SettingsPage.About);
public ICommand ExportSettingsCommand { get; }
public ICommand ImportSettingsCommand { get; }
@@ -1138,6 +1130,7 @@ public sealed class SettingsViewModel : SectionViewModel
[
JobKind.Render, JobKind.Import, JobKind.Download, JobKind.UploadCommit, JobKind.Scan, JobKind.Rebuild, JobKind.Verify, JobKind.LightAnalyse,
JobKind.DeepAnalyse, JobKind.Thumbs, JobKind.Proxies, JobKind.Maintenance, JobKind.Duplicates, JobKind.Orphans, JobKind.Adopt, JobKind.Move,
JobKind.Backup, JobKind.Cleanup,
];
/// <summary>Stores <paramref name="level"/> for <paramref name="kind"/>, keeping only the levels that differ from the defaults.</summary>
@@ -1310,7 +1303,8 @@ public sealed class SettingsViewModel : SectionViewModel
if (Shell.Services.Database is not { } db) return;
try
{
var path = await db.BackupAsync(Shell.Services.Environment.BackupDirectory, DatabaseBackups.Keep);
// As many copies stay as the backup schedules keep (Jobs › Scheduled › Index backup › Copies kept).
var path = await db.BackupAsync(Shell.Services.Environment.BackupDirectory, await DatabaseBackups.KeptAsync(db));
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is DatabaseException or IOException or NotSupportedException)
@@ -1344,7 +1338,7 @@ public sealed class SettingsViewModel : SectionViewModel
/// Restore (BRIEF §6.2, §12.8): a dry run reads what the chosen copy holds against the index now (shown as unreadable
/// when the index did not open, the case a restore exists for); after the user's destructive confirmation the copy is
/// staged beside the index for the next start, where the index as it is then is kept first and replaced before it is
/// opened (<see cref="DatabaseBackups.RestoreStagedAsync"/>; the staged copy is out of reach of the pruning to three
/// opened (<see cref="DatabaseBackups.RestoreStagedAsync"/>; the staged copy is out of reach of the pruning of the
/// copies). Nothing replaces the index while Chronos runs.
/// </summary>
private async Task RestoreDatabaseAsync()
@@ -1494,6 +1488,9 @@ public sealed class SettingsViewModel : SectionViewModel
case SettingsPage.Updates:
_s.CheckForUpdates = defaults.CheckForUpdates;
break;
case SettingsPage.Advanced:
Logs.Reset();
break;
}
Save();
OnAllPropertiesChanged();
@@ -1514,7 +1511,6 @@ public sealed class SettingsViewModel : SectionViewModel
_s.FileTemplate = defaults.FileTemplate;
_s.ProxyLongEdge = defaults.ProxyLongEdge;
_s.ThumbnailLongEdge = defaults.ThumbnailLongEdge;
_s.ScanIntervalMinutes = defaults.ScanIntervalMinutes;
FolderTemplate.Load(_s.FolderTemplate);
FileTemplate.Load(_s.FileTemplate);
UpdatePreview();
@@ -1599,6 +1595,7 @@ public sealed class SettingsViewModel : SectionViewModel
DefaultServer.Load(ServerAddress.Display(_s.ServerUrl));
_interfacePriority?.Update();
foreach (var row in JobPriorities) row.Refresh();
Logs.Refresh();
UpdatePreview();
LoadCertificates();
OnAllPropertiesChanged();
@@ -1673,6 +1670,7 @@ public sealed class SettingsViewModel : SectionViewModel
foreach (var row in JobPriorities) row.Refresh();
foreach (var row in Formats) row.Refresh();
foreach (var row in MissingExtensions) row.Refresh();
Logs.Refresh();
ArchiveRoot.Refresh();
FolderTemplate.Refresh();
FileTemplate.Refresh();