From 47045fc57145135626032cd5397e5bbfcfcb4eed Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 28 Apr 2018 22:10:47 +0200 Subject: [PATCH] Added some MAL jobs to the UI --- pages/editor/jobs/jobs.go | 9 +++++++++ pages/editor/jobs/start.go | 7 +++++++ 2 files changed, 16 insertions(+) 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") {