mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 08:03:52 +09:00
Merge pull request #12609 from peppy/fix-download-button-import-cancel-state
Fix import cancellation not correctly being forwarded to import notification
This commit is contained in:
@ -43,7 +43,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
createButtonWithBeatmap(createSoleily());
|
createButtonWithBeatmap(createSoleily());
|
||||||
AddAssert("button state not downloaded", () => downloadButton.DownloadState == DownloadState.NotDownloaded);
|
AddAssert("button state not downloaded", () => downloadButton.DownloadState == DownloadState.NotDownloaded);
|
||||||
AddStep("import soleily", () => beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()));
|
AddStep("import soleily", () => beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()));
|
||||||
|
|
||||||
AddUntilStep("wait for beatmap import", () => beatmaps.GetAllUsableBeatmapSets().Any(b => b.OnlineBeatmapSetID == 241526));
|
AddUntilStep("wait for beatmap import", () => beatmaps.GetAllUsableBeatmapSets().Any(b => b.OnlineBeatmapSetID == 241526));
|
||||||
|
AddAssert("button state downloaded", () => downloadButton.DownloadState == DownloadState.LocallyAvailable);
|
||||||
|
|
||||||
createButtonWithBeatmap(createSoleily());
|
createButtonWithBeatmap(createSoleily());
|
||||||
AddAssert("button state downloaded", () => downloadButton.DownloadState == DownloadState.LocallyAvailable);
|
AddAssert("button state downloaded", () => downloadButton.DownloadState == DownloadState.LocallyAvailable);
|
||||||
ensureSoleilyRemoved();
|
ensureSoleilyRemoved();
|
||||||
|
@ -156,33 +156,44 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
|
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
|
||||||
|
|
||||||
await Task.WhenAll(tasks.Select(async task =>
|
try
|
||||||
{
|
{
|
||||||
notification.CancellationToken.ThrowIfCancellationRequested();
|
await Task.WhenAll(tasks.Select(async task =>
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var model = await Import(task, isLowPriorityImport, notification.CancellationToken).ConfigureAwait(false);
|
notification.CancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
lock (imported)
|
try
|
||||||
{
|
{
|
||||||
if (model != null)
|
var model = await Import(task, isLowPriorityImport, notification.CancellationToken).ConfigureAwait(false);
|
||||||
imported.Add(model);
|
|
||||||
current++;
|
|
||||||
|
|
||||||
notification.Text = $"Imported {current} of {tasks.Length} {HumanisedModelName}s";
|
lock (imported)
|
||||||
notification.Progress = (float)current / tasks.Length;
|
{
|
||||||
|
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)
|
if (imported.Count == 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user