1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 23:12:56 +08:00

Merge pull request #20136 from smoogipoo/fix-cancellation-perf

Improve performance when cancelling import with debugger attached
This commit is contained in:
Dean Herbert 2022-09-05 22:03:50 +09:00 committed by GitHub
commit 6296c971f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,11 +108,10 @@ namespace osu.Game.Database
bool isBatchImport = tasks.Length >= minimum_items_considered_batch_import; bool isBatchImport = tasks.Length >= minimum_items_considered_batch_import;
try
{
await Task.WhenAll(tasks.Select(async task => await Task.WhenAll(tasks.Select(async task =>
{ {
notification.CancellationToken.ThrowIfCancellationRequested(); if (notification.CancellationToken.IsCancellationRequested)
return;
try try
{ {
@ -128,27 +127,23 @@ namespace osu.Game.Database
notification.Progress = (float)current / tasks.Length; notification.Progress = (float)current / tasks.Length;
} }
} }
catch (TaskCanceledException) catch (OperationCanceledException)
{ {
throw;
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database); Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database);
} }
})).ConfigureAwait(false); })).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
if (imported.Count == 0) if (imported.Count == 0)
{
if (notification.CancellationToken.IsCancellationRequested)
{ {
notification.State = ProgressNotificationState.Cancelled; notification.State = ProgressNotificationState.Cancelled;
return imported; return imported;
} }
}
if (imported.Count == 0)
{
notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!"; notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import failed!";
notification.State = ProgressNotificationState.Cancelled; notification.State = ProgressNotificationState.Cancelled;
} }