diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-09-12 18:58:24 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-09-12 18:58:24 -0400 |
commit | 1b7adf57e94aaccd2abc6c7288947e36bb311c0a (patch) | |
tree | c45836d27d10807df9d047548b0ec3a0aec03e01 /models/webhook.go | |
parent | cfed11f092580ecf47cff43274c7cdd10d07bffd (diff) | |
download | gitea-1b7adf57e94aaccd2abc6c7288947e36bb311c0a.tar.gz gitea-1b7adf57e94aaccd2abc6c7288947e36bb311c0a.zip |
fix https://github.com/go-xorm/xorm/issues/161
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/models/webhook.go b/models/webhook.go index 5c0e217975..3c07cc8179 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -236,6 +236,7 @@ func UpdateHookTask(t *HookTask) error { // DeliverHooks checks and delivers undelivered hooks. func DeliverHooks() { + tasks := make([]*HookTask, 0, 10) timeout := time.Duration(setting.WebhookDeliverTimeout) * time.Second x.Where("is_delivered=?", false).Iterate(new(HookTask), func(idx int, bean interface{}) error { @@ -283,12 +284,18 @@ func DeliverHooks() { } } - if err := UpdateHookTask(t); err != nil { - log.Error(4, "UpdateHookTask: %v", err) - return nil - } + tasks = append(tasks, t) - log.Trace("Hook delivered(%s): %s", t.Uuid, t.PayloadContent) + if t.IsSucceed { + log.Trace("Hook delivered(%s): %s", t.Uuid, t.PayloadContent) + } return nil }) + + // Update hook task status. + for _, t := range tasks { + if err := UpdateHookTask(t); err != nil { + log.Error(4, "UpdateHookTask(%d): %v", t.Id, err) + } + } } |