From 4e05b8e97c5d0dc989cf1d3e2838436cabe98bae Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 13 Apr 2024 22:36:41 +0200 Subject: [PATCH] fix(project): do not crash when duplicating a project with no tasks --- pkg/models/project_duplicate.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/models/project_duplicate.go b/pkg/models/project_duplicate.go index dbc38d2af..0ee15f8a1 100644 --- a/pkg/models/project_duplicate.go +++ b/pkg/models/project_duplicate.go @@ -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 }