1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-21 08:31:27 -05:00

Fix unexpected context canceled when migrating repository (#27368)

Fix #27363

Regression of #27089
This commit is contained in:
CaiCandong 2023-10-01 20:04:35 +08:00 committed by GitHub
parent 7ad31567cd
commit 87aa552531
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,11 +47,11 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) {
err = fmt.Errorf("PANIC whilst trying to do migrate task: %v", e) err = fmt.Errorf("PANIC whilst trying to do migrate task: %v", e)
log.Critical("PANIC during runMigrateTask[%d] by DoerID[%d] to RepoID[%d] for OwnerID[%d]: %v\nStacktrace: %v", t.ID, t.DoerID, t.RepoID, t.OwnerID, e, log.Stack(2)) log.Critical("PANIC during runMigrateTask[%d] by DoerID[%d] to RepoID[%d] for OwnerID[%d]: %v\nStacktrace: %v", t.ID, t.DoerID, t.RepoID, t.OwnerID, e, log.Stack(2))
} }
// fixme: Because ctx is canceled here, so the db.DefaultContext is needed.
if err == nil { if err == nil {
err = admin_model.FinishMigrateTask(ctx, t) err = admin_model.FinishMigrateTask(db.DefaultContext, t)
if err == nil { if err == nil {
notify_service.MigrateRepository(ctx, t.Doer, t.Owner, t.Repo) notify_service.MigrateRepository(db.DefaultContext, t.Doer, t.Owner, t.Repo)
return return
} }
@ -63,8 +63,8 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) {
t.EndTime = timeutil.TimeStampNow() t.EndTime = timeutil.TimeStampNow()
t.Status = structs.TaskStatusFailed t.Status = structs.TaskStatusFailed
t.Message = err.Error() t.Message = err.Error()
// fixme: Because ctx is canceled here, so the db.DefaultContext is needed.
if err := t.UpdateCols(ctx, "status", "message", "end_time"); err != nil { if err := t.UpdateCols(db.DefaultContext, "status", "message", "end_time"); err != nil {
log.Error("Task UpdateCols failed: %v", err) log.Error("Task UpdateCols failed: %v", err)
} }