1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 18:30:21 +08:00

Remove async from Populate method

This commit is contained in:
Dean Herbert
2022-01-13 16:27:07 +09:00
Unverified
parent 70c107b434
commit bdb2979b2e
4 changed files with 9 additions and 18 deletions
+1 -4
View File
@@ -5,7 +5,6 @@ using System;
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 @@ namespace osu.Game.Scoring
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 @@ namespace osu.Game.Scoring
if (string.IsNullOrEmpty(model.StatisticsJson))
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
return Task.CompletedTask;
}
public override bool IsAvailableLocally(ScoreInfo model)
+1 -4
View File
@@ -7,7 +7,6 @@ using System.IO;
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 @@ namespace osu.Game.Skinning
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 @@ namespace osu.Game.Skinning
model.InstantiationInfo = createInstance(model).GetType().GetInvariantInstantiationInfo();
checkSkinIniMetadata(model, realm);
return Task.CompletedTask;
}
private void checkSkinIniMetadata(SkinInfo item, Realm realm)
+1 -4
View File
@@ -6,7 +6,6 @@ using System.Collections.Generic;
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 @@ namespace osu.Game.Stores
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 @@ namespace osu.Game.Stores
LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs");
}
}
return Task.CompletedTask;
}
protected override void PreImport(BeatmapSetInfo beatmapSet, Realm realm)
+6 -6
View File
@@ -318,7 +318,7 @@ namespace osu.Game.Stores
/// <param name="archive">An optional archive to use for model population.</param>
/// <param name="lowPriority">Whether this is a low priority import.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
public virtual async Task<ILive<TModel>?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
public virtual Task<ILive<TModel>?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
{
using (var realm = ContextFactory.CreateContext())
{
@@ -352,7 +352,7 @@ namespace osu.Game.Stores
transaction.Commit();
}
return existing.ToLive(ContextFactory);
return Task.FromResult((ILive<TModel>?)existing.ToLive(ContextFactory));
}
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
@@ -373,7 +373,7 @@ namespace osu.Game.Stores
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 @@ namespace osu.Game.Stores
existing.DeletePending = false;
transaction.Commit();
return existing.ToLive(ContextFactory);
return Task.FromResult((ILive<TModel>?)existing.ToLive(ContextFactory));
}
LogForModel(item, @"Found existing but failed re-use check.");
@@ -413,7 +413,7 @@ namespace osu.Game.Stores
throw;
}
return item.ToLive(ContextFactory);
return Task.FromResult((ILive<TModel>?)item.ToLive(ContextFactory));
}
}
@@ -480,7 +480,7 @@ namespace osu.Game.Stores
/// <param name="archive">The archive to use as a reference for population. May be null.</param>
/// <param name="realm">The current realm context.</param>
/// <param name="cancellationToken">An optional cancellation token.</param>
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);
/// <summary>
/// Perform any final actions before the import to database executes.