Skip to content

Commit ab30b89

Browse files
committed
Restart the task scheduling scan with the initially larger window every 6 hours.
1 parent b2394d4 commit ab30b89

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/lib/task/backend.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,14 @@ class TaskBackend {
289289
// Map from package to updated that has been seen.
290290
final seen = <String, DateTime>{};
291291

292+
// The scan process will give up control after 6 hours and the restart
293+
// will trigger the 3-days period scan at the beginning of the loop.
294+
final stopAfter = clock.fromNow(hours: 6);
295+
292296
// In theory 30 minutes overlap should be enough. In practice we should
293-
// allow an ample room for missed windows, and 3 days seems to be large enough.
297+
// allow an ample room for missed windows, and 3 days seems to be large enough
298+
// for the initial scan. Subsequent scans will run with a shorter (5-minutes)
299+
// window.
294300
var since = clock.ago(days: 3);
295301
while (claim.valid && !abort.isCompleted) {
296302
// Look at all packages changed in [since]
@@ -326,6 +332,11 @@ class TaskBackend {
326332
// be relevant to the next iteration.
327333
seen.removeWhere((_, updated) => updated.isBefore(since));
328334

335+
// Do not start waiting if after that we would be over the stop threshold.
336+
if (clock.fromNow(minutes: 10).isAfter(stopAfter)) {
337+
break;
338+
}
339+
329340
// Wait until aborted or 10 minutes before scanning again!
330341
await abort.future.timeout(Duration(minutes: 10), onTimeout: () => null);
331342
}

0 commit comments

Comments
 (0)