fixed starting cron jobs when importing
This commit is contained in:
parent
03f8d8cec7
commit
aad3f3437f
1 changed files with 11 additions and 9 deletions
20
main.go
20
main.go
|
@ -419,15 +419,6 @@ func (web *Web) importWatch(c *gin.Context) {
|
||||||
filterMap[filter.ID] = filter
|
filterMap[filter.ID] = filter
|
||||||
filter.ID = 0
|
filter.ID = 0
|
||||||
filter.WatchID = uint(watchID)
|
filter.WatchID = uint(watchID)
|
||||||
if filter.Type == "cron" {
|
|
||||||
entryID, err := web.cron.AddFunc(filter.Var1, func() { triggerSchedule(filter.WatchID, web) })
|
|
||||||
if err != nil {
|
|
||||||
log.Println("Could not start job for Watch: ", filter.WatchID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Println("Started CronJob for WatchID", filter.WatchID, "with schedule:", filter.Var1)
|
|
||||||
web.cronWatch[filter.ID] = web.cron.Entry(entryID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
web.db.Delete(&Filter{}, "watch_id = ?", watchID)
|
web.db.Delete(&Filter{}, "watch_id = ?", watchID)
|
||||||
|
|
||||||
|
@ -437,6 +428,17 @@ func (web *Web) importWatch(c *gin.Context) {
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
for _, filter := range export.Filters {
|
||||||
|
if filter.Type == "cron" {
|
||||||
|
entryID, err := web.cron.AddFunc(filter.Var1, func() { triggerSchedule(filter.WatchID, web) })
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Could not start job for Watch: ", filter.WatchID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Println("Started CronJob for WatchID", filter.WatchID, "with schedule:", filter.Var1)
|
||||||
|
web.cronWatch[filter.ID] = web.cron.Entry(entryID)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
web.db.Delete(&FilterConnection{}, "watch_id = ?", watchID)
|
web.db.Delete(&FilterConnection{}, "watch_id = ?", watchID)
|
||||||
|
|
Loading…
Add table
Reference in a new issue