feat: add shared media assets and fix credit lifecycle

This commit is contained in:
OpenClaw Agent
2026-09-17 02:30:31 +08:00
parent 7d79d43b61
commit b853a239ff
11 changed files with 351 additions and 19 deletions
+4 -2
View File
@@ -33,7 +33,7 @@ func (a *App) reserveCredit(userID, taskID uint, amount int64) (*CreditReservati
}
}
var existing CreditReservation
if err := tx.Where("task_id = ?", taskID).First(&existing).Error; err == nil {
if err := tx.Where("task_id = ? AND status = ?", taskID, "reserved").Order("id desc").First(&existing).Error; err == nil {
reservation = existing
return nil
} else if !errors.Is(err, gorm.ErrRecordNotFound) {
@@ -106,7 +106,9 @@ func (a *App) refundCredit(task *Task) error {
return nil
}
if r.Status == "committed" {
return errReservationState
// A committed reservation belongs to a completed download. A later
// storage/retry error must never debit or refund it a second time.
return nil
}
if r.Status != "reserved" {
return errReservationState