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:
parent
f6f18e2fe2
commit
2a87b851fa
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user