diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-10-18 12:34:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 10:34:39 +0000 |
commit | 83186eca80d2b1586c1a46ff238de32e5a448f95 (patch) | |
tree | d20429bb966404f5ae73822785ea36d575506779 /services/actions | |
parent | 4e98224a4501238286ee3fd5ed911958951da9b0 (diff) | |
download | gitea-83186eca80d2b1586c1a46ff238de32e5a448f95.tar.gz gitea-83186eca80d2b1586c1a46ff238de32e5a448f95.zip |
Always delete existing scheduled action tasks (#27662)
Fixes #27650
Diffstat (limited to 'services/actions')
-rw-r--r-- | services/actions/notifier_helper.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index ff00e48c64..7d5f6c6c0a 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -374,11 +374,6 @@ func handleSchedules( commit *git.Commit, input *notifyInput, ) error { - if len(detectedWorkflows) == 0 { - log.Trace("repo %s with commit %s couldn't find schedules", input.Repo.RepoPath(), commit.ID) - return nil - } - branch, err := commit.GetBranchName() if err != nil { return err @@ -388,18 +383,20 @@ func handleSchedules( return nil } - rows, _, err := actions_model.FindSchedules(ctx, actions_model.FindScheduleOptions{RepoID: input.Repo.ID}) - if err != nil { - log.Error("FindCrons: %v", err) + if count, err := actions_model.CountSchedules(ctx, actions_model.FindScheduleOptions{RepoID: input.Repo.ID}); err != nil { + log.Error("CountSchedules: %v", err) return err - } - - if len(rows) > 0 { + } else if count > 0 { if err := actions_model.DeleteScheduleTaskByRepo(ctx, input.Repo.ID); err != nil { log.Error("DeleteCronTaskByRepo: %v", err) } } + if len(detectedWorkflows) == 0 { + log.Trace("repo %s with commit %s couldn't find schedules", input.Repo.RepoPath(), commit.ID) + return nil + } + p, err := json.Marshal(input.Payload) if err != nil { return fmt.Errorf("json.Marshal: %w", err) |