diff options
author | 6543 <6543@obermui.de> | 2020-04-17 19:42:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 20:42:57 +0300 |
commit | 12960b9d1861c9e7b0b5c7076dec029de80a1944 (patch) | |
tree | 1be5df2d4ba6829a6bc066cede732c1f77373cd4 /modules/migrations | |
parent | 0010fde8a2c813b02b78c8c806716f9725b3b6c3 (diff) | |
download | gitea-12960b9d1861c9e7b0b5c7076dec029de80a1944.tar.gz gitea-12960b9d1861c9e7b0b5c7076dec029de80a1944.zip |
[BugFix] remove nil inserts in models (#11096)
* Fix InsertReleases Nil Insert on Attachments
* FIX "No element on slice when insert" & smal refactor
* again
* impruve
* rm useles newline
* Apply suggestions from code review
Co-Authored-By: zeripath <art27@cantab.net>
* process insert as a whole
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/migrations')
-rw-r--r-- | modules/migrations/gitea.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index a087cafe9d..8da1bd4683 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -393,13 +393,16 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { iss = append(iss, &is) } - err := models.InsertIssues(iss...) - if err != nil { - return err - } - for _, is := range iss { - g.issues.Store(is.Index, is.ID) + if len(iss) > 0 { + if err := models.InsertIssues(iss...); err != nil { + return err + } + + for _, is := range iss { + g.issues.Store(is.Index, is.ID) + } } + return nil } @@ -478,6 +481,9 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { cms = append(cms, &cm) } + if len(cms) == 0 { + return nil + } return models.InsertIssueComments(cms) } |