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

Fix import cancellation not correctly being forwarded to import notification

This commit is contained in:
Dean Herbert 2021-04-28 15:54:58 +09:00
parent ac1534cda2
commit 05e3a73a7d

View File

@ -156,33 +156,44 @@ namespace osu.Game.Database
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
await Task.WhenAll(tasks.Select(async task =>
try
{
notification.CancellationToken.ThrowIfCancellationRequested();
try
await Task.WhenAll(tasks.Select(async task =>
{
var model = await Import(task, isLowPriorityImport, notification.CancellationToken).ConfigureAwait(false);
notification.CancellationToken.ThrowIfCancellationRequested();
lock (imported)
try
{
if (model != null)
imported.Add(model);
current++;
var model = await Import(task, isLowPriorityImport, notification.CancellationToken).ConfigureAwait(false);
notification.Text = $"Imported {current} of {tasks.Length} {HumanisedModelName}s";
notification.Progress = (float)current / tasks.Length;
lock (imported)
{
if (model != null)
imported.Add(model);
current++;
notification.Text = $"Imported {current} of {tasks.Length} {HumanisedModelName}s";
notification.Progress = (float)current / tasks.Length;
}
}
}
catch (TaskCanceledException)
catch (TaskCanceledException)
{
throw;
}
catch (Exception e)
{
Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database);
}
})).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
if (imported.Count == 0)
{
throw;
notification.State = ProgressNotificationState.Cancelled;
return imported;
}
catch (Exception e)
{
Logger.Error(e, $@"Could not import ({task})", LoggingTarget.Database);
}
})).ConfigureAwait(false);
}
if (imported.Count == 0)
{