diff --git a/osu.Game/Scoring/ScoreModelManager.cs b/osu.Game/Scoring/ScoreModelManager.cs index 09a5919f12..fcf7244226 100644 --- a/osu.Game/Scoring/ScoreModelManager.cs +++ b/osu.Game/Scoring/ScoreModelManager.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Logging; using osu.Framework.Platform; @@ -55,7 +54,7 @@ public ScoreModelManager(RulesetStore rulesets, Func beatmaps, S public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store); - protected override Task Populate(ScoreInfo model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) + protected override void Populate(ScoreInfo model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) { // Ensure the beatmap is not detached. if (!model.BeatmapInfo.IsManaged) @@ -66,8 +65,6 @@ protected override Task Populate(ScoreInfo model, ArchiveReader? archive, Realm if (string.IsNullOrEmpty(model.StatisticsJson)) model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics); - - return Task.CompletedTask; } public override bool IsAvailableLocally(ScoreInfo model) diff --git a/osu.Game/Skinning/SkinModelManager.cs b/osu.Game/Skinning/SkinModelManager.cs index dbd209e984..b8313f63a3 100644 --- a/osu.Game/Skinning/SkinModelManager.cs +++ b/osu.Game/Skinning/SkinModelManager.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Text; using System.Threading; -using System.Threading.Tasks; using Newtonsoft.Json; using osu.Framework.Logging; using osu.Framework.Platform; @@ -49,7 +48,7 @@ public SkinModelManager(Storage storage, RealmContextFactory contextFactory, Gam protected override bool HasCustomHashFunction => true; - protected override Task Populate(SkinInfo model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) + protected override void Populate(SkinInfo model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) { var skinInfoFile = model.Files.SingleOrDefault(f => f.Filename == skin_info_file); @@ -83,8 +82,6 @@ protected override Task Populate(SkinInfo model, ArchiveReader? archive, Realm r model.InstantiationInfo = createInstance(model).GetType().GetInvariantInstantiationInfo(); checkSkinIniMetadata(model, realm); - - return Task.CompletedTask; } private void checkSkinIniMetadata(SkinInfo item, Realm realm) diff --git a/osu.Game/Stores/BeatmapImporter.cs b/osu.Game/Stores/BeatmapImporter.cs index 429d3951cf..53971b1d96 100644 --- a/osu.Game/Stores/BeatmapImporter.cs +++ b/osu.Game/Stores/BeatmapImporter.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using osu.Framework.Audio.Track; using osu.Framework.Extensions; using osu.Framework.Extensions.IEnumerableExtensions; @@ -53,7 +52,7 @@ protected BeatmapImporter(RealmContextFactory contextFactory, Storage storage, B protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path).ToLowerInvariant() == ".osz"; - protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) + protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default) { if (archive != null) beatmapSet.Beatmaps.AddRange(createBeatmapDifficulties(beatmapSet.Files, realm)); @@ -87,8 +86,6 @@ protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader? archi LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs"); } } - - return Task.CompletedTask; } protected override void PreImport(BeatmapSetInfo beatmapSet, Realm realm) diff --git a/osu.Game/Stores/RealmArchiveModelImporter.cs b/osu.Game/Stores/RealmArchiveModelImporter.cs index 9927840c4e..bcae9f2451 100644 --- a/osu.Game/Stores/RealmArchiveModelImporter.cs +++ b/osu.Game/Stores/RealmArchiveModelImporter.cs @@ -318,7 +318,7 @@ protected virtual string ComputeHash(TModel item) /// An optional archive to use for model population. /// Whether this is a low priority import. /// An optional cancellation token. - public virtual async Task?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default) + public virtual Task?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default) { using (var realm = ContextFactory.CreateContext()) { @@ -352,7 +352,7 @@ protected virtual string ComputeHash(TModel item) transaction.Commit(); } - return existing.ToLive(ContextFactory); + return Task.FromResult((ILive?)existing.ToLive(ContextFactory)); } LogForModel(item, @"Found existing (optimised) but failed pre-check."); @@ -373,7 +373,7 @@ protected virtual string ComputeHash(TModel item) item.Hash = ComputeHash(item); // TODO: we may want to run this outside of the transaction. - await Populate(item, archive, realm, cancellationToken).ConfigureAwait(false); + Populate(item, archive, realm, cancellationToken); if (!checkedExisting) existing = CheckForExisting(item, realm); @@ -387,7 +387,7 @@ protected virtual string ComputeHash(TModel item) existing.DeletePending = false; transaction.Commit(); - return existing.ToLive(ContextFactory); + return Task.FromResult((ILive?)existing.ToLive(ContextFactory)); } LogForModel(item, @"Found existing but failed re-use check."); @@ -413,7 +413,7 @@ protected virtual string ComputeHash(TModel item) throw; } - return item.ToLive(ContextFactory); + return Task.FromResult((ILive?)item.ToLive(ContextFactory)); } } @@ -480,7 +480,7 @@ private List createFileInfos(ArchiveReader reader, RealmFil /// The archive to use as a reference for population. May be null. /// The current realm context. /// An optional cancellation token. - protected abstract Task Populate(TModel model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default); + protected abstract void Populate(TModel model, ArchiveReader? archive, Realm realm, CancellationToken cancellationToken = default); /// /// Perform any final actions before the import to database executes.