| 329 | } |
| 330 | |
| 331 | func RenewSystemTaskLock(taskID string, lockedBy string, lockUntil int64) error { |
| 332 | now := common.GetTimestamp() |
| 333 | result := DB.Model(&SystemTaskLock{}). |
| 334 | Where("task_id = ? AND locked_by = ? AND locked_until >= ?", taskID, lockedBy, now). |
| 335 | Updates(map[string]any{ |
| 336 | "locked_until": lockUntil, |
| 337 | "updated_at": now, |
| 338 | }) |
| 339 | if result.Error != nil { |
| 340 | return result.Error |
| 341 | } |
| 342 | if result.RowsAffected == 0 { |
| 343 | return ErrSystemTaskLockLost |
| 344 | } |
| 345 | return nil |
| 346 | } |
| 347 | |
| 348 | func MarkSystemTaskLeaseExpired(taskID string) error { |
| 349 | result := DB.Model(&SystemTask{}). |