aboutsummaryrefslogtreecommitdiffstats
path: root/services/cron/tasks.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/cron/tasks.go')
-rw-r--r--services/cron/tasks.go9
1 files changed, 9 insertions, 0 deletions
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 {