aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/cron/cron.go6
-rw-r--r--services/cron/tasks.go9
2 files changed, 15 insertions, 0 deletions
diff --git a/services/cron/cron.go b/services/cron/cron.go
index e3f31d08f0..63db75ab3b 100644
--- a/services/cron/cron.go
+++ b/services/cron/cron.go
@@ -106,6 +106,12 @@ func ListTasks() TaskTable {
next = e.NextRun()
prev = e.PreviousRun()
}
+
+ // If the manual run is after the cron run, use that instead.
+ if prev.Before(task.LastRun) {
+ prev = task.LastRun
+ }
+
task.lock.Lock()
tTable = append(tTable, &TaskTableRow{
Name: task.Name,
diff --git a/services/cron/tasks.go b/services/cron/tasks.go
index ea1925c26c..d2c3d1d812 100644
--- a/services/cron/tasks.go
+++ b/services/cron/tasks.go
@@ -9,6 +9,7 @@ import (
"reflect"
"strings"
"sync"
+ "time"
"code.gitea.io/gitea/models/db"
system_model "code.gitea.io/gitea/models/system"
@@ -37,6 +38,8 @@ type Task struct {
LastMessage string
LastDoer string
ExecTimes int64
+ // This stores the time of the last manual run of this task.
+ LastRun time.Time
}
// DoRunAtStart returns if this task should run at the start
@@ -88,6 +91,12 @@ func (t *Task) RunWithUser(doer *user_model.User, config Config) {
}
}()
graceful.GetManager().RunWithShutdownContext(func(baseCtx context.Context) {
+ // Store the time of this run, before the function is executed, so it
+ // matches the behavior of what the cron library does.
+ t.lock.Lock()
+ t.LastRun = time.Now()
+ t.lock.Unlock()
+
pm := process.GetManager()
doerName := ""
if doer != nil && doer.ID != -1 {