fix: one audit retention, scans at start, live deep analysis and a 6-hour upload sweep

Settle what the R10 scheduler and R11 log packages left open when they were
integrated (owner review 2, phase 2).

- Audit retention has one source of truth, the audit-cleanup schedule's age
  limit. AuditRetentionDays defaults to 0 (the audit log is kept forever, so
  an upgrade deletes nothing; the schedule is seeded off) and accepts 0-3650,
  what a schedule's age limit takes. Saving Settings › Logs › Keep audit sets
  the schedule's limit (on with a limit, off at 0) without a restart;
  CHRONOS_AUDIT_RETENTION_DAYS locks it and Reset goes back to it.
- Both hosts scan right after start again, as their polling did: the server
  after the scheduler starts, the desktop once the archive was reopened and
  again when an unplugged one is back. Scheduler.RunSystemNowAsync runs the
  archive-scan schedule when it is enabled and has not run since the start,
  and skips while its scan is pending.
- Desktop scans follow Settings › Analysis › After a scan at every run: a scan
  schedule without its own deep parameter asks the host
  (IScheduleHost.DeepAnalysisAfterScan), the archive-scan schedule no longer
  freezes the setting, and the editor offers deep only for analyses, so the
  setting's tooltip stays true.
- The server's upload clean-up runs every 6 hours instead of every 30
  minutes, to keep the job history readable; idle uploads still expire after
  UploadRetentionHours.
- The Unraid template and docker-compose leave CHRONOS_LOG_LEVEL empty or
  commented out, and say that setting it locks both log levels, so the admin
  panel can change them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-27 02:51:04 +01:00
1 parent bc786c12c4
commit 8d66be709c
21 files changed
+299 -53

No files matched your search

+29 -5
View File
@@ -288,10 +288,11 @@ public sealed class AppServices : IAsyncDisposable
/// <summary>
/// At start, off the UI thread: reopens the archive at Settings › Archive's folder (a moved one relinked, interrupted
/// renames finished), then starts the schedules, whose first pass settles the runs missed while Chronos was closed. An
/// archive whose archive.json is not there (an unplugged drive) is looked for every <see cref="ReopenInterval"/> until
/// it is back, then the schedules look at once for a due run; unless the folder changed meanwhile: whatever changed it
/// opened the new archive. The app's exit waits for this on the UI thread.
/// renames finished), then starts the schedules, whose first pass settles the runs missed while Chronos was closed, and
/// runs the archive scan once, as the rescans did at start (<see cref="ScanNowAsync"/>). An archive whose archive.json is
/// not there (an unplugged drive) is looked for every <see cref="ReopenInterval"/> until it is back, then scanned and the
/// schedules look at once for a due run; unless the folder changed meanwhile: whatever changed it opened the new
/// archive. The app's exit waits for this on the UI thread.
/// </summary>
private async Task RunSchedulesAsync(CancellationToken ct)
{
@@ -299,13 +300,19 @@ public sealed class AppServices : IAsyncDisposable
try
{
if (reopen is not null && await ReopenAsync(reopen, ct).ConfigureAwait(false)) reopen = null;
var started = SchedulerTime.GetUtcNow();
await StartSchedulerAsync(ct).ConfigureAwait(false);
if (reopen is null) return;
if (reopen is null)
{
await ScanNowAsync(started, ct).ConfigureAwait(false);
return;
}
using var timer = new PeriodicTimer(ReopenInterval);
while (await timer.WaitForNextTickAsync(ct).ConfigureAwait(false))
{
if (!string.Equals(reopen, Settings.LastArchivePath, StringComparison.OrdinalIgnoreCase)) return;
if (!await ReopenAsync(reopen, ct).ConfigureAwait(false)) continue;
await ScanNowAsync(null, ct).ConfigureAwait(false);
Scheduler?.Wake();
return;
}
@@ -324,6 +331,23 @@ public sealed class AppServices : IAsyncDisposable
}
}
/// <summary>
/// Runs the archive scan schedule once now when it is enabled (owner review 2, R10: the archive was opened or is back),
/// unless it ran since <paramref name="since"/> (the first pass fired it) or its scan is still pending.
/// </summary>
private async Task ScanNowAsync(DateTimeOffset? since, CancellationToken ct)
{
if (Scheduler is not { } scheduler) return;
try
{
await scheduler.RunSystemNowAsync(DesktopScheduleHost.ArchiveScan, since, ct).ConfigureAwait(false);
}
catch (Exception ex) when (ex is DatabaseException or IOException or InvalidOperationException)
{
Log.Warning("schedules", "The archive scan could not be run now; its schedule runs the next one", ex);
}
}
/// <summary>
/// Starts <see cref="Scheduler"/> on this PC's engine: it seeds the system schedules and runs its first pass before
/// <see cref="SchedulerReady"/> turns true. Without an engine, or when the schedules cannot be read, there is none.
+6 -2
View File
@@ -21,7 +21,8 @@ namespace Chronos.App.Jobs;
/// drive). The system schedules stand for the timers the desktop used to run out of sight: the archive scan (its interval
/// carried over from the former Settings › Archive › Rescan every, <see cref="AppSettings.ScanIntervalMinutes"/>, once:
/// a row that exists keeps the user's edits), the daily index backup, and the housekeeping clean-up at 04:00 (job history,
/// cache trim). Thread-safe: the scheduler calls it from its loop.
/// cache trim). Scans give what they find a deep analysis as Settings › Analysis › After a scan says at each run
/// (<see cref="DeepAnalysisAfterScan"/>), like the scans started by hand. Thread-safe: the scheduler calls it from its loop.
/// </summary>
public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDatabase?> database, Func<ArchiveService?> archives) : IScheduleHost
{
@@ -43,7 +44,7 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
public IReadOnlyList<SystemSchedule> SystemSchedules =>
[
new(ArchiveScan, "Archive scan", ScheduleActions.Scan, ScheduleRecurrence.Interval(ScanMinutes(settings), RecurrenceUnit.Minutes),
new ScheduleParametersDto(Force: false, Deep: settings.DeepAnalysisAfterScan), CatchUp: false),
new ScheduleParametersDto(Force: false), CatchUp: false),
new(IndexBackup, "Index backup", ScheduleActions.Backup, ScheduleRecurrence.Interval(1, RecurrenceUnit.Days),
new ScheduleParametersDto(Keep: DatabaseBackups.Keep)),
new(Housekeeping, "Housekeeping", ScheduleActions.Cleanup, ScheduleRecurrence.DailyAt(HousekeepingTime),
@@ -83,6 +84,9 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
/// <summary>The desktop runs every action its engine has a handler for.</summary>
public string? Unavailable(string action) => null;
/// <summary>Settings › Analysis › After a scan, read at every run: a scheduled scan follows it as a scan started by hand does.</summary>
public bool DeepAnalysisAfterScan => settings.DeepAnalysisAfterScan;
}
/// <summary>
@@ -268,7 +268,8 @@ public sealed class ScheduleEditorViewModel : LocalizedViewModel
// ---------------- Parameters ----------------
public bool ShowsForce => _action.Name is ScheduleActions.Scan or ScheduleActions.Thumbnails or ScheduleActions.Proxies;
public bool ShowsDeep => _action.Name is ScheduleActions.Scan or ScheduleActions.Analysis;
/// <summary>Analysis only: a scan's deep analysis follows Settings › Analysis › After a scan at every run.</summary>
public bool ShowsDeep => _action.Name == ScheduleActions.Analysis;
public bool ShowsOlderThan => _action.Name is ScheduleActions.Verify or ScheduleActions.Cleanup;
public bool ShowsPercent => _action.Name == ScheduleActions.Verify;
public bool ShowsDryRun => _action.Name == ScheduleActions.Maintenance;
@@ -294,7 +295,7 @@ public sealed class ScheduleEditorViewModel : LocalizedViewModel
set => Set(ref _deep, value);
}
public string DeepToolTip => Loc.L(_action.Name == ScheduleActions.Scan ? "Tooltips.Jobs.Editor.DeepAfterScan" : "Tooltips.Jobs.Editor.DeepAnalysis");
public string DeepToolTip => Loc.L("Tooltips.Jobs.Editor.DeepAnalysis");
public bool DryRun
{