Skip to content

Commit

Permalink
fix nil stmt panic
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Apr 3, 2024
1 parent 4f764fc commit f95d938
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions database/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ func (db *SqlDB) setupSubscribeQuestionMark(ctx context.Context) (err error) {
if db.subscribeStmts.setUpdateScopesOnly, err = db.db.PrepareContext(ctx, setUpdateScopesOnlyCmd); err != nil {
return
}
if db.subscribeStmts.setUpdateLastReportOnly, err = db.db.PrepareContext(ctx, setUpdateLastReportOnlyCmd); err != nil {
return
}

const removeDeleteCmd = "DELETE FROM " + tableName +
" WHERE `user`=? AND `client`=?"
Expand Down
8 changes: 7 additions & 1 deletion notify/email/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ var tmpl = func() *template.Template {
return "", fmt.Errorf("Except string or bytes, got %T", v)
}
},
"tojson": json.Marshal,
"tojson": func(v any) (string, error) {
buf, err := json.Marshal(v)
if err != nil {
return "", err
}
return (string)(buf), nil
},
})
template.Must(t.ParseFS(tmplFS, "**/*.gohtml"))
return t
Expand Down
6 changes: 6 additions & 0 deletions notify/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (m *Manager) OnEnabled() {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnEnabled(e)
}(p)
}
Expand All @@ -116,6 +117,7 @@ func (m *Manager) OnDisabled() {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnDisabled(e)
}(p)
}
Expand All @@ -137,6 +139,7 @@ func (m *Manager) OnSyncBegin(count int, size int64) {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnSyncBegin(e)
}(p)
}
Expand All @@ -154,6 +157,7 @@ func (m *Manager) OnSyncDone() {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnSyncDone(e)
}(p)
}
Expand All @@ -176,6 +180,7 @@ func (m *Manager) OnUpdateAvaliable(release *update.GithubRelease) {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnUpdateAvaliable(e)
}(p)
}
Expand Down Expand Up @@ -208,6 +213,7 @@ func (m *Manager) OnReportStatus(stats *Stats) {
res := make(chan error, 0)
for _, p := range m.plugins {
go func(p Plugin) {
defer log.RecoverPanic()
res <- p.OnReportStatus(e)
}(p)
}
Expand Down

0 comments on commit f95d938

Please sign in to comment.