change the order of stopSchedule
This commit is contained in:
@@ -1505,13 +1505,16 @@ func stopScheduleGCP(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteSchedule(ctx context.Context, id string) error {
|
func deleteKeySchedule(ctx context.Context, id string) error {
|
||||||
log.Printf("[DEBUG] Should stop schedule %s!", id)
|
|
||||||
err := shuffle.DeleteKey(ctx, "schedules", id)
|
err := shuffle.DeleteKey(ctx, "schedules", id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed to delete schedule: %s", err)
|
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func deleteSchedule(ctx context.Context, id string) error {
|
||||||
|
log.Printf("[DEBUG] Should stop schedule %s!", id)
|
||||||
if value, exists := scheduledJobs[id]; exists {
|
if value, exists := scheduledJobs[id]; exists {
|
||||||
// Stops the schedule properly
|
// Stops the schedule properly
|
||||||
value.Lock()
|
value.Lock()
|
||||||
@@ -1524,11 +1527,17 @@ func deleteSchedule(ctx context.Context, id string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Just stop and delete anyway if not in memory
|
||||||
|
deleteKeySchedule(ctx, id)
|
||||||
return errors.New("Can't find the schedule.")
|
return errors.New("Can't find the schedule.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
err := deleteKeySchedule(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERROR] Failed to stop schedule in db %s: %s", id, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user