mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 18:20:11 +00:00
Use async transactions for AddSwitch
This commit is contained in:
parent
37b99f9521
commit
767a37e637
1 changed files with 2 additions and 2 deletions
|
|
@ -236,7 +236,7 @@ namespace PluralKit.Core {
|
||||||
{
|
{
|
||||||
// Use a transaction here since we're doing multiple executed commands in one
|
// Use a transaction here since we're doing multiple executed commands in one
|
||||||
await using var conn = await _conn.Obtain();
|
await using var conn = await _conn.Obtain();
|
||||||
using var tx = await conn.BeginTransactionAsync();
|
await using var tx = await conn.BeginTransactionAsync();
|
||||||
|
|
||||||
// First, we insert the switch itself
|
// First, we insert the switch itself
|
||||||
var sw = await conn.QuerySingleAsync<PKSwitch>("insert into switches(system) values (@System) returning *",
|
var sw = await conn.QuerySingleAsync<PKSwitch>("insert into switches(system) values (@System) returning *",
|
||||||
|
|
@ -252,7 +252,7 @@ namespace PluralKit.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally we commit the tx, since the using block will otherwise rollback it
|
// Finally we commit the tx, since the using block will otherwise rollback it
|
||||||
tx.Commit();
|
await tx.CommitAsync();
|
||||||
|
|
||||||
_logger.Information("Registered switch {Switch} in system {System} with members {@Members}", sw.Id, system.Id, members.Select(m => m.Id));
|
_logger.Information("Registered switch {Switch} in system {System} with members {@Members}", sw.Id, system.Id, members.Select(m => m.Id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue