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

@@ -26,7 +26,8 @@ public sealed class DesktopScheduleHostTests(TestContext context)
var scan = Assert.NotNull(await fx.Db.Schedules.GetBySystemKeyAsync(DesktopScheduleHost.ArchiveScan));
Assert.Equal(("every:30m", false, JobPriority.Background, true, ScheduleActions.Scan), (scan.Recurrence, scan.CatchUp, scan.Priority, scan.Enabled, scan.Action));
Assert.Equal(true, ScheduleMapping.Parameters(scan).Deep);
// The deep analysis is not frozen into the schedule: each run reads Settings › Analysis › After a scan.
Assert.Null(ScheduleMapping.Parameters(scan).Deep);
Assert.Equal(fx.Clock.Now.AddMinutes(30), scan.NextRun);
// The user edits the schedule in Jobs › Scheduled; the old setting changes (or never changes again): the next
@@ -43,6 +44,52 @@ public sealed class DesktopScheduleHostTests(TestContext context)
Assert.Equal("every:5m", (await fx.Db.Schedules.GetAsync(scan.Id))!.Recurrence);
}
/// <summary>
/// Owner review 2, R10: the scheduled scans follow Settings › Analysis › After a scan as it is at each run, like the
/// scans started by hand, so that checkbox's tooltip stays true; and the archive is scanned right after it was opened
/// (once per start, and again when an unplugged archive is back), as the rescans did.
/// </summary>
[Test]
public async Task TheScanRunsAtOnceAndFollowsTheDeepAnalysisSettingAtEachRun()
{
var settings = new AppSettings { Language = "en", DeepAnalysisAfterScan = false };
await using var fx = await ScheduleFixture.CreateAsync(context, settings);
var archive = await fx.Archives.CreateAsync(Path.Combine(fx.Folder, "archive"), "archive");
settings.LastArchivePath = archive.RootPath;
var started = fx.Clock.Now;
var scheduler = await fx.StartAsync();
// Right after the start, not one interval later.
var first = Assert.NotNull(await scheduler.RunSystemNowAsync(DesktopScheduleHost.ArchiveScan, started));
Assert.Equal(ScheduleOutcome.Queued, first.Outcome);
Assert.False(await DeepAsync(fx, first.JobId!.Value));
Assert.Null(await scheduler.RunSystemNowAsync(DesktopScheduleHost.ArchiveScan, started));
// The setting changes after the schedule was seeded: the next run follows it.
settings.DeepAnalysisAfterScan = true;
await fx.Db.Jobs.SetStateAsync(first.JobId!.Value, JobState.Done);
var second = Assert.NotNull(await scheduler.RunSystemNowAsync(DesktopScheduleHost.ArchiveScan));
Assert.Equal(ScheduleOutcome.Queued, second.Outcome);
Assert.True(await DeepAsync(fx, second.JobId!.Value));
Assert.True(fx.Host.DeepAnalysisAfterScan);
// The editor offers no deep switch for a scan (only for an analysis), so a scan schedule never freezes it.
using var vm = await fx.ViewModelAsync();
vm.NewCommand.Execute(null);
var editor = Assert.NotNull(vm.Editor);
editor.SelectedAction = editor.ActionOptions.Single(a => a.Name == ScheduleActions.Scan);
Assert.True(editor.ShowsForce && !editor.ShowsDeep, "a scan's switches: a full scan only");
}
/// <summary>Whether the scan job <paramref name="id"/> gives what it finds a deep analysis.</summary>
private static async Task<bool> DeepAsync(ScheduleFixture fx, Guid id)
{
var job = Assert.NotNull(await fx.Db.Jobs.GetAsync(id));
Assert.Equal(JobKind.Scan, job.Kind);
using var parameters = System.Text.Json.JsonDocument.Parse(job.ParametersJson!);
return parameters.RootElement.GetProperty("deepAnalysis").GetBoolean();
}
[Test]
public void TheFormerIntervalIsClampedToWhatAnIntervalAccepts()
{