From cf3ed42bfc9e299c599e4215ab72ea2df69f7940 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 Oct 2019 17:41:42 +0900 Subject: [PATCH] Fix download tracking components getting stuck on import failures --- osu.Game/Database/ArchiveModelManager.cs | 4 +++- osu.Game/Database/DownloadableArchiveModelManager.cs | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index b567f0c0e3..9fed8e03ac 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -108,7 +108,7 @@ public Task Import(params string[] paths) return Import(notification, paths); } - protected async Task Import(ProgressNotification notification, params string[] paths) + protected async Task> Import(ProgressNotification notification, params string[] paths) { notification.Progress = 0; notification.Text = $"{HumanisedModelName.Humanize(LetterCasing.Title)} import is initialising..."; @@ -168,6 +168,8 @@ await Task.WhenAll(paths.Select(async path => notification.State = ProgressNotificationState.Completed; } + + return imported; } /// diff --git a/osu.Game/Database/DownloadableArchiveModelManager.cs b/osu.Game/Database/DownloadableArchiveModelManager.cs index 78c0837ce9..e3c6ad25e6 100644 --- a/osu.Game/Database/DownloadableArchiveModelManager.cs +++ b/osu.Game/Database/DownloadableArchiveModelManager.cs @@ -76,7 +76,12 @@ public bool Download(TModel model, bool minimiseDownloadSize = false) Task.Factory.StartNew(async () => { // This gets scheduled back to the update thread, but we want the import to run in the background. - await Import(notification, filename); + var imported = await Import(notification, filename); + + // for now a failed import will be marked as a failed download for simplicity. + if (!imported.Any()) + DownloadFailed?.Invoke(request); + currentDownloads.Remove(request); }, TaskCreationOptions.LongRunning); };