fixed SIGSEGV if no messages are present
This commit is contained in:
@@ -511,13 +511,15 @@ func (p *DemoParser) parseWorker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bulk := make([]*ent.MessagesCreate, len(tMatchPlayer.Edges.Messages))
|
bulk := make([]*ent.MessagesCreate, 0)
|
||||||
for _, msg := range tMatchPlayer.Edges.Messages {
|
for _, msg := range tMatchPlayer.Edges.Messages {
|
||||||
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetMatchPlayer(tMatchPlayer))
|
bulk = append(bulk, p.db.Messages.Create().SetMessage(msg.Message).SetAllChat(msg.AllChat).SetMatchPlayer(tMatchPlayer))
|
||||||
}
|
}
|
||||||
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
|
if len(bulk) > 0 {
|
||||||
if err != nil {
|
err = p.db.Messages.CreateBulk(bulk...).Exec(context.Background())
|
||||||
log.Warningf("[DP] Failure adding messages to database: %v", err)
|
if err != nil {
|
||||||
|
log.Warningf("[DP] Failure adding messages to database: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
main.go
3
main.go
@@ -1046,6 +1046,9 @@ func main() {
|
|||||||
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
||||||
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
|
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
|
||||||
|
|
||||||
|
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
||||||
|
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
|
||||||
|
|
||||||
router.HandleFunc(`/matches`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
router.HandleFunc(`/matches`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
|
||||||
router.HandleFunc(`/matches`, getMatches).Methods(http.MethodGet)
|
router.HandleFunc(`/matches`, getMatches).Methods(http.MethodGet)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user