mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-28 21:41:22 +08:00
[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>
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user