mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 22:36:14 -06:00
slightly improved mentiondb err handling
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
parent
57ccbb9e38
commit
5c9d9e1c54
1 changed files with 8 additions and 8 deletions
|
|
@ -53,13 +53,13 @@ func (m *mentionDB) mentionCached(id string) (*gtsmodel.Mention, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mI, err := m.cache.Fetch(id)
|
mI, err := m.cache.Fetch(id)
|
||||||
if err != nil || mI == nil {
|
if err != nil {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
mention, ok := mI.(*gtsmodel.Mention)
|
mention, ok := mI.(*gtsmodel.Mention)
|
||||||
if !ok {
|
if !ok || mention == nil {
|
||||||
m.log.Panicf("mentionDB: cached interface with key %s was not a mention", id)
|
m.log.Panicf("mentionDB: cached interface with key %s (%T) was not a mention", id, mention)
|
||||||
}
|
}
|
||||||
|
|
||||||
return mention, true
|
return mention, true
|
||||||
|
|
@ -85,12 +85,12 @@ func (m *mentionDB) GetMention(ctx context.Context, id string) (*gtsmodel.Mentio
|
||||||
Where("mention.id = ?", id)
|
Where("mention.id = ?", id)
|
||||||
|
|
||||||
err := m.conn.ProcessError(q.Scan(ctx))
|
err := m.conn.ProcessError(q.Scan(ctx))
|
||||||
|
if err != nil {
|
||||||
if err == nil && mention != nil {
|
return nil, err
|
||||||
m.cacheMention(id, mention)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mention, err
|
m.cacheMention(id, mention)
|
||||||
|
return mention, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mentionDB) GetMentions(ctx context.Context, ids []string) ([]*gtsmodel.Mention, db.Error) {
|
func (m *mentionDB) GetMentions(ctx context.Context, ids []string) ([]*gtsmodel.Mention, db.Error) {
|
||||||
|
|
@ -99,7 +99,7 @@ func (m *mentionDB) GetMentions(ctx context.Context, ids []string) ([]*gtsmodel.
|
||||||
for _, i := range ids {
|
for _, i := range ids {
|
||||||
mention, err := m.GetMention(ctx, i)
|
mention, err := m.GetMention(ctx, i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, m.conn.ProcessError(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
mentions = append(mentions, mention)
|
mentions = append(mentions, mention)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue