mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:42:58 +08:00
Only lock the database for the duration of a deletion (#6363)
Only lock the database for the duration of a deletion
This commit is contained in:
commit
cbdf42cd7b
@ -400,20 +400,17 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
using (ContextFactory.GetForWrite())
|
foreach (var b in items)
|
||||||
{
|
{
|
||||||
foreach (var b in items)
|
if (notification.State == ProgressNotificationState.Cancelled)
|
||||||
{
|
// user requested abort
|
||||||
if (notification.State == ProgressNotificationState.Cancelled)
|
return;
|
||||||
// user requested abort
|
|
||||||
return;
|
|
||||||
|
|
||||||
notification.Text = $"Deleting {HumanisedModelName}s ({++i} of {items.Count})";
|
notification.Text = $"Deleting {HumanisedModelName}s ({++i} of {items.Count})";
|
||||||
|
|
||||||
Delete(b);
|
Delete(b);
|
||||||
|
|
||||||
notification.Progress = (float)i / items.Count;
|
notification.Progress = (float)i / items.Count;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
@ -439,20 +436,17 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
using (ContextFactory.GetForWrite())
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
if (notification.State == ProgressNotificationState.Cancelled)
|
||||||
{
|
// user requested abort
|
||||||
if (notification.State == ProgressNotificationState.Cancelled)
|
return;
|
||||||
// user requested abort
|
|
||||||
return;
|
|
||||||
|
|
||||||
notification.Text = $"Restoring ({++i} of {items.Count})";
|
notification.Text = $"Restoring ({++i} of {items.Count})";
|
||||||
|
|
||||||
Undelete(item);
|
Undelete(item);
|
||||||
|
|
||||||
notification.Progress = (float)i / items.Count;
|
notification.Progress = (float)i / items.Count;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
|
Loading…
Reference in New Issue
Block a user