fix(migration): don't try to add nonexistent tasks as related
Discussion: https://community.vikunja.io/t/todoist-migration-fails-after-51-iterations-19-minutes/1137
This commit is contained in:
parent
4a05d1a497
commit
58da38adb6
@ -369,14 +369,14 @@ func convertTodoistToVikunja(sync *sync, doneItems map[string]*doneItem) (fullVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the parenId of a task is not 0, create a task relation
|
// If the parenId of a task is not 0, create a task relation
|
||||||
// We're looping again here to make sure we have seem all tasks before and have them in our map
|
// We're looping again here to make sure we have seen all tasks before and have them in our map
|
||||||
for _, i := range sync.Items {
|
for _, i := range sync.Items {
|
||||||
if i.ParentID == "" {
|
if i.ParentID == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, exists := tasks[i.ParentID]; !exists {
|
if _, exists := tasks[i.ParentID]; !exists {
|
||||||
log.Debugf("[Todoist Migration] Could not find task %s in tasks map while trying to get resolve subtasks for task %s", i.ParentID, i.ID)
|
log.Debugf("[Todoist Migration] Could not find task %s in tasks map while trying to resolve subtasks for task %s", i.ParentID, i.ID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,6 +385,11 @@ func convertTodoistToVikunja(sync *sync, doneItems map[string]*doneItem) (fullVi
|
|||||||
tasks[i.ParentID].RelatedTasks = make(models.RelatedTaskMap)
|
tasks[i.ParentID].RelatedTasks = make(models.RelatedTaskMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, exists := tasks[i.ID]; !exists {
|
||||||
|
log.Debugf("[Todoist Migration] Could not find task %s in tasks map while trying to add it as subtask", i.ID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
tasks[i.ParentID].RelatedTasks[models.RelationKindSubtask] = append(tasks[i.ParentID].RelatedTasks[models.RelationKindSubtask], &tasks[i.ID].Task)
|
tasks[i.ParentID].RelatedTasks[models.RelationKindSubtask] = append(tasks[i.ParentID].RelatedTasks[models.RelationKindSubtask], &tasks[i.ID].Task)
|
||||||
|
|
||||||
// Remove the task from the top level structure, otherwise it is added twice
|
// Remove the task from the top level structure, otherwise it is added twice
|
||||||
|
Loading…
x
Reference in New Issue
Block a user