Added some MAL jobs to the UI

This commit is contained in:
Eduard Urbach 2018-04-28 22:10:47 +02:00
parent 262b6018d1
commit 47045fc571
2 changed files with 16 additions and 0 deletions

View File

@ -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{}

View File

@ -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") {