mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-17 11:03:11 -06:00
Use writer to avoid locked databases
This commit is contained in:
parent
26a639fa19
commit
9300caf243
|
|
@ -195,10 +195,14 @@ func (d *Database) QueryPushRules(
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal default push rules: %w", err)
|
||||
}
|
||||
if err := d.AccountDatas.InsertAccountData(ctx, nil, localpart, "", "m.push_rules", json.RawMessage(prbs)); err != nil {
|
||||
return nil, fmt.Errorf("failed to save default push rules: %w", err)
|
||||
}
|
||||
return pushRuleSets, nil
|
||||
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||
if dbErr := d.AccountDatas.InsertAccountData(ctx, txn, localpart, "", "m.push_rules", prbs); dbErr != nil {
|
||||
return fmt.Errorf("failed to save default push rules: %w", dbErr)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return pushRuleSets, err
|
||||
}
|
||||
|
||||
var pushRules pushrules.AccountRuleSets
|
||||
|
|
|
|||
Loading…
Reference in a new issue