From 2481c0b64bc2158d710f8cdc57d6efcc4b05f5f3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 27 Sep 2023 17:02:47 +0900 Subject: [PATCH] Don't show replay import "missing beatmap" notifications during stable import Closes https://github.com/ppy/osu/issues/24926. --- osu.Game/Beatmaps/BeatmapImporter.cs | 2 +- osu.Game/Database/RealmArchiveModelImporter.cs | 5 +++-- osu.Game/Scoring/ScoreImporter.cs | 14 +++++++++----- osu.Game/Skinning/SkinImporter.cs | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapImporter.cs b/osu.Game/Beatmaps/BeatmapImporter.cs index b497b8e8dc..e89e5339e1 100644 --- a/osu.Game/Beatmaps/BeatmapImporter.cs +++ b/osu.Game/Beatmaps/BeatmapImporter.cs @@ -280,7 +280,7 @@ protected override void UndeleteForReuse(BeatmapSetInfo existing) public override string HumanisedModelName => "beatmap"; - protected override BeatmapSetInfo? CreateModel(ArchiveReader reader) + protected override BeatmapSetInfo? CreateModel(ArchiveReader reader, ImportParameters parameters) { // let's make sure there are actually .osu files to import. string? mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu", StringComparison.OrdinalIgnoreCase)); diff --git a/osu.Game/Database/RealmArchiveModelImporter.cs b/osu.Game/Database/RealmArchiveModelImporter.cs index 9d06c14b4b..581ed41f75 100644 --- a/osu.Game/Database/RealmArchiveModelImporter.cs +++ b/osu.Game/Database/RealmArchiveModelImporter.cs @@ -229,7 +229,7 @@ await Task.WhenAll(tasks.Select(async task => try { - model = CreateModel(archive); + model = CreateModel(archive, parameters); if (model == null) return null; @@ -474,8 +474,9 @@ private List createFileInfos(ArchiveReader reader, RealmFil /// Actual expensive population should be done in ; this should just prepare for duplicate checking. /// /// The archive to create the model for. + /// Parameters to further configure the import process. /// A model populated with minimal information. Returning a null will abort importing silently. - protected abstract TModel? CreateModel(ArchiveReader archive); + protected abstract TModel? CreateModel(ArchiveReader archive, ImportParameters parameters); /// /// Populate the provided model completely from the given archive. diff --git a/osu.Game/Scoring/ScoreImporter.cs b/osu.Game/Scoring/ScoreImporter.cs index b85b6a066e..28e70cff4f 100644 --- a/osu.Game/Scoring/ScoreImporter.cs +++ b/osu.Game/Scoring/ScoreImporter.cs @@ -42,7 +42,7 @@ public ScoreImporter(RulesetStore rulesets, Func beatmaps, Stora this.api = api; } - protected override ScoreInfo? CreateModel(ArchiveReader archive) + protected override ScoreInfo? CreateModel(ArchiveReader archive, ImportParameters parameters) { string name = archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase)); @@ -56,10 +56,14 @@ public ScoreImporter(RulesetStore rulesets, Func beatmaps, Stora { Logger.Log($@"Score '{archive.Name}' failed to import: no corresponding beatmap with the hash '{e.Hash}' could be found.", LoggingTarget.Database); - // In the case of a missing beatmap, let's attempt to resolve it and show a prompt to the user to download the required beatmap. - var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = e.Hash }); - req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, e.Hash)); - api.Queue(req); + if (!parameters.Batch) + { + // In the case of a missing beatmap, let's attempt to resolve it and show a prompt to the user to download the required beatmap. + var req = new GetBeatmapRequest(new BeatmapInfo { MD5Hash = e.Hash }); + req.Success += res => PostNotification?.Invoke(new MissingBeatmapNotification(res, archive, e.Hash)); + api.Queue(req); + } + return null; } } diff --git a/osu.Game/Skinning/SkinImporter.cs b/osu.Game/Skinning/SkinImporter.cs index f2103a45c4..b543197296 100644 --- a/osu.Game/Skinning/SkinImporter.cs +++ b/osu.Game/Skinning/SkinImporter.cs @@ -39,7 +39,7 @@ public SkinImporter(Storage storage, RealmAccess realm, IStorageResourceProvider protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path).ToLowerInvariant() == @".osk"; - protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name ?? @"No name" }; + protected override SkinInfo? CreateModel(ArchiveReader archive, ImportParameters parameters) => new SkinInfo { Name = archive.Name ?? @"No name" }; private const string unknown_creator_string = @"Unknown";