diff --git a/pages/editor/jobs/jobs.go b/pages/editor/jobs/jobs.go index 2e54ab58..1b24a510 100644 --- a/pages/editor/jobs/jobs.go +++ b/pages/editor/jobs/jobs.go @@ -18,6 +18,15 @@ var jobInfo = map[string]*utils.JobInfo{ "refresh-osu": &utils.JobInfo{ Name: "refresh-osu", }, + "mal-download": &utils.JobInfo{ + Name: "mal-download", + }, + "mal-parse": &utils.JobInfo{ + Name: "mal-parse", + }, + // "mal-sync": &utils.JobInfo{ + // Name: "mal-sync", + // }, } var jobLogs = []string{} diff --git a/pages/editor/jobs/start.go b/pages/editor/jobs/start.go index 5ed7acea..7560c035 100644 --- a/pages/editor/jobs/start.go +++ b/pages/editor/jobs/start.go @@ -2,6 +2,7 @@ package jobs import ( "net/http" + "sync" "github.com/animenotifier/arn" @@ -9,8 +10,14 @@ import ( "github.com/animenotifier/notify.moe/utils" ) +// Only allow one job to be started at a time +var jobStartMutex sync.Mutex + // Start will start the specified background job. func Start(ctx *aero.Context) string { + jobStartMutex.Lock() + defer jobStartMutex.Unlock() + user := utils.GetUser(ctx) if user == nil || (user.Role != "editor" && user.Role != "admin") {