fix(project): do not crash when duplicating a project with no tasks
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2024-04-13 22:36:41 +02:00
parent 5177f516c4
commit 4e05b8e97c
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 4 deletions

View File

@ -226,9 +226,11 @@ func duplicateViews(s *xorm.Session, pd *ProjectDuplicate, doer web.Auth, taskMa
})
}
_, err = s.Insert(&taskBuckets)
if err != nil {
return err
if len(taskBuckets) > 0 {
_, err = s.Insert(&taskBuckets)
if err != nil {
return err
}
}
oldTaskPositions := []*TaskPosition{}
@ -246,7 +248,9 @@ func duplicateViews(s *xorm.Session, pd *ProjectDuplicate, doer web.Auth, taskMa
})
}
_, err = s.Insert(&taskPositions)
if len(taskPositions) > 0 {
_, err = s.Insert(&taskPositions)
}
return
}