Skip to content

Commit

Permalink
Don't start old tasks, just in case people have them in their database
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Aug 15, 2023
1 parent 13908a9 commit 66d2292
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tasks/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/turt2live/matrix-media-repo/database"
"github.com/turt2live/matrix-media-repo/notifier"
"github.com/turt2live/matrix-media-repo/tasks/task_runner"
"github.com/turt2live/matrix-media-repo/util"
"github.com/turt2live/matrix-media-repo/util/ids"
)

Expand Down Expand Up @@ -61,6 +62,13 @@ func beginTask(task *database.DbTask) {
}
// TODO: Worker group: https://github.com/turt2live/matrix-media-repo/issues/425
runnerCtx := rcontext.Initial().LogWithFields(logrus.Fields{"task_id": task.TaskId})

oneHourAgo := util.NowMillis() - (60 * 60 * 1000)
if task.StartTs < oneHourAgo {
runnerCtx.Log.Warn("Not starting task because it is more than 1 hour old.")
return
}

if task.Name == string(TaskDatastoreMigrate) {
go task_runner.DatastoreMigrate(runnerCtx, task)
} else if task.Name == string(TaskExportData) {
Expand Down

0 comments on commit 66d2292

Please sign in to comment.