fixed starting cron jobs when importing
This commit is contained in:
parent
03f8d8cec7
commit
aad3f3437f
1 changed files with 11 additions and 9 deletions
18
main.go
18
main.go
|
@ -419,6 +419,16 @@ func (web *Web) importWatch(c *gin.Context) {
|
|||
filterMap[filter.ID] = filter
|
||||
filter.ID = 0
|
||||
filter.WatchID = uint(watchID)
|
||||
}
|
||||
web.db.Delete(&Filter{}, "watch_id = ?", watchID)
|
||||
|
||||
if len(export.Filters) > 0 {
|
||||
tx := web.db.Create(&export.Filters)
|
||||
if tx.Error != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
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 {
|
||||
|
@ -429,14 +439,6 @@ func (web *Web) importWatch(c *gin.Context) {
|
|||
web.cronWatch[filter.ID] = web.cron.Entry(entryID)
|
||||
}
|
||||
}
|
||||
web.db.Delete(&Filter{}, "watch_id = ?", watchID)
|
||||
|
||||
if len(export.Filters) > 0 {
|
||||
tx := web.db.Create(&export.Filters)
|
||||
if tx.Error != nil {
|
||||
c.AbortWithError(http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
web.db.Delete(&FilterConnection{}, "watch_id = ?", watchID)
|
||||
|
|
Loading…
Add table
Reference in a new issue