From 767a37e63747931db1a0f5a506e2c6f6a342c580 Mon Sep 17 00:00:00 2001 From: Ske Date: Sat, 13 Jun 2020 19:14:42 +0200 Subject: [PATCH] Use async transactions for AddSwitch --- PluralKit.Core/Services/PostgresDataStore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PluralKit.Core/Services/PostgresDataStore.cs b/PluralKit.Core/Services/PostgresDataStore.cs index 70562071..cf41cfff 100644 --- a/PluralKit.Core/Services/PostgresDataStore.cs +++ b/PluralKit.Core/Services/PostgresDataStore.cs @@ -236,7 +236,7 @@ namespace PluralKit.Core { { // Use a transaction here since we're doing multiple executed commands in one 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 var sw = await conn.QuerySingleAsync("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 - 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)); }