fix(server): archive.json on its own timer, a live Scheduled tab in one time zone, schedule audit in words
- SchedulerHost reads archive.json every 10 minutes on its own timer. The archive-scan runs that used to do it are skipped while a long scan is pending, and the schedule may be off or daily, so uploads kept a desktop's old folder template or proxy size. - Every schedule change and run, a skipped run included, is published as a scheduleChanged event. The Scheduled tab reloads on it, so skipped runs, next-run moves and other administrators' edits show without waiting for a job. - The Scheduled tab still draws when the schedule a job links to, or an expanded one, no longer exists: its runs are dropped instead of failing the whole load. - Every time on the Scheduled tab (next run, last result, runs) is in the server's time zone, as its "Times in" line says. - Audit details name a system schedule after its key (system:<key> · name · ...). The dashboard and the Logs page show it by its localized name and the recurrence code in words, as the Scheduled tab does. Older entries keep their recorded name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c20f573d0bdf1cdcf3a86e9702ac76a4bf9508d9)
This commit is contained in:
1 parent
e384564784
commit
3f0e6357b1
10 files changed
+339
-43
No files matched your search
@@ -128,6 +128,89 @@ public sealed class ManualTimeProvider : TimeProvider
|
||||
public void Advance(TimeSpan by) => Interlocked.Add(ref _ticks, by.Ticks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A clock tests move by hand whose timers (<see cref="PeriodicTimer"/>, <c>Task.Delay</c>, timed cancellation) fire only
|
||||
/// when <see cref="Advance"/> reaches them, never in real time: the loops paced by it run exactly when a test says.
|
||||
/// </summary>
|
||||
public sealed class SteppedTimeProvider : TimeProvider
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
private readonly List<SteppedTimer> _timers = [];
|
||||
private DateTimeOffset _now = DateTimeOffset.UtcNow;
|
||||
|
||||
public override DateTimeOffset GetUtcNow()
|
||||
{
|
||||
lock (_gate) return _now;
|
||||
}
|
||||
|
||||
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
var timer = new SteppedTimer(this, callback, state);
|
||||
timer.Change(dueTime, period);
|
||||
return timer;
|
||||
}
|
||||
|
||||
/// <summary>Moves the clock on, then fires each timer due by then once (a periodic one moves to its next period after now).</summary>
|
||||
public void Advance(TimeSpan by)
|
||||
{
|
||||
List<SteppedTimer> due;
|
||||
lock (_gate)
|
||||
{
|
||||
_now += by;
|
||||
due = [.. _timers.Where(t => t.Due <= _now)];
|
||||
foreach (var timer in due)
|
||||
{
|
||||
if (timer.Period <= TimeSpan.Zero) _timers.Remove(timer);
|
||||
else
|
||||
{
|
||||
while (timer.Due <= _now) timer.Due += timer.Period;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var timer in due) timer.Fire();
|
||||
}
|
||||
|
||||
private void Schedule(SteppedTimer timer, TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_timers.Remove(timer);
|
||||
if (dueTime == Timeout.InfiniteTimeSpan) return;
|
||||
timer.Due = _now + dueTime;
|
||||
timer.Period = period == Timeout.InfiniteTimeSpan ? TimeSpan.Zero : period;
|
||||
_timers.Add(timer);
|
||||
}
|
||||
}
|
||||
|
||||
private void Remove(SteppedTimer timer)
|
||||
{
|
||||
lock (_gate) _timers.Remove(timer);
|
||||
}
|
||||
|
||||
private sealed class SteppedTimer(SteppedTimeProvider clock, TimerCallback callback, object? state) : ITimer
|
||||
{
|
||||
public DateTimeOffset Due { get; set; }
|
||||
|
||||
public TimeSpan Period { get; set; }
|
||||
|
||||
public bool Change(TimeSpan dueTime, TimeSpan period)
|
||||
{
|
||||
clock.Schedule(this, dueTime, period);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Fire() => callback(state);
|
||||
|
||||
public void Dispose() => clock.Remove(this);
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
Dispose();
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A job handler that reports progress and then waits until <see cref="Release"/> (or cancellation), so tests can
|
||||
/// observe running, paused and cancelled states.
|
||||
|
||||
Reference in new issue
Block a user