1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 14:52:55 +08:00

Add proper transaction rollback logic on exception

This commit is contained in:
Dean Herbert 2018-05-28 18:38:42 +09:00
parent f6f18e2fe2
commit 2a87b851fa

View File

@ -28,8 +28,19 @@ namespace osu.Game.Database
if (isDisposed) return; if (isDisposed) return;
isDisposed = true; isDisposed = true;
PerformedWrite |= Context.SaveChanges(transaction) > 0; try
usageCompleted?.Invoke(this); {
PerformedWrite |= Context.SaveChanges(transaction) > 0;
}
catch (Exception e)
{
transaction?.Rollback();
throw;
}
finally
{
usageCompleted?.Invoke(this);
}
} }
public void Dispose() public void Dispose()