fix(migration): do not crash when relating a task to itself
Resolves https://community.vikunja.io/t/vikunja-import-error-tried-to-relate-a-task-with-itself/1105
This commit is contained in:
parent
c6cade3aeb
commit
2ead48c1e9
|
|
@ -352,6 +352,13 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas
|
|||
if ttt, exists := tasksByOldID[rt.ID]; exists {
|
||||
taskRel.OtherTaskID = ttt.ID
|
||||
}
|
||||
|
||||
// Add this check to prevent self-relations
|
||||
if taskRel.TaskID == taskRel.OtherTaskID {
|
||||
log.Debugf("[creating structure] Skipping invalid self-relation for task %d", taskRel.TaskID)
|
||||
continue
|
||||
}
|
||||
|
||||
err = taskRel.Create(s, user)
|
||||
if err != nil && !models.IsErrRelationAlreadyExists(err) {
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in New Issue