aboutsummaryrefslogtreecommitdiffstats
path: root/modules/task
diff options
context:
space:
mode:
Diffstat (limited to 'modules/task')
-rw-r--r--modules/task/migrate.go3
-rw-r--r--modules/task/task.go6
2 files changed, 6 insertions, 3 deletions
diff --git a/modules/task/migrate.go b/modules/task/migrate.go
index 52f4bb91cf..715e76b4ad 100644
--- a/modules/task/migrate.go
+++ b/modules/task/migrate.go
@@ -58,6 +58,9 @@ func runMigrateTask(t *models.Task) (err error) {
t.EndTime = timeutil.TimeStampNow()
t.Status = structs.TaskStatusFailed
t.Message = err.Error()
+ // Ensure that the repo loaded before we zero out the repo ID from the task - thus ensuring that we can delete it
+ _ = t.LoadRepo()
+
t.RepoID = 0
if err := t.UpdateCols("status", "errors", "repo_id", "end_time"); err != nil {
log.Error("Task UpdateCols failed: %v", err)
diff --git a/modules/task/task.go b/modules/task/task.go
index 4e782869f9..51377df78c 100644
--- a/modules/task/task.go
+++ b/modules/task/task.go
@@ -90,7 +90,7 @@ func CreateMigrateTask(doer, u *models.User, opts base.MigrateOptions) (*models.
return nil, err
}
- var task = models.Task{
+ var task = &models.Task{
DoerID: doer.ID,
OwnerID: u.ID,
Type: structs.TaskTypeMigrateRepo,
@@ -98,7 +98,7 @@ func CreateMigrateTask(doer, u *models.User, opts base.MigrateOptions) (*models.
PayloadContent: string(bs),
}
- if err := models.CreateTask(&task); err != nil {
+ if err := models.CreateTask(task); err != nil {
return nil, err
}
@@ -126,5 +126,5 @@ func CreateMigrateTask(doer, u *models.User, opts base.MigrateOptions) (*models.
return nil, err
}
- return &task, nil
+ return task, nil
}