mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Remove async
from Populate
method
This commit is contained in:
parent
70c107b434
commit
bdb2979b2e
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -55,7 +54,7 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public Score GetScore(ScoreInfo score) => new LegacyDatabasedScore(score, rulesets, beatmaps(), Files.Store);
|
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.
|
// Ensure the beatmap is not detached.
|
||||||
if (!model.BeatmapInfo.IsManaged)
|
if (!model.BeatmapInfo.IsManaged)
|
||||||
@ -66,8 +65,6 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(model.StatisticsJson))
|
if (string.IsNullOrEmpty(model.StatisticsJson))
|
||||||
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
|
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsAvailableLocally(ScoreInfo model)
|
public override bool IsAvailableLocally(ScoreInfo model)
|
||||||
|
@ -7,7 +7,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
@ -49,7 +48,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override bool HasCustomHashFunction => true;
|
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);
|
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();
|
model.InstantiationInfo = createInstance(model).GetType().GetInvariantInstantiationInfo();
|
||||||
|
|
||||||
checkSkinIniMetadata(model, realm);
|
checkSkinIniMetadata(model, realm);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkSkinIniMetadata(SkinInfo item, Realm realm)
|
private void checkSkinIniMetadata(SkinInfo item, Realm realm)
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
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 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)
|
if (archive != null)
|
||||||
beatmapSet.Beatmaps.AddRange(createBeatmapDifficulties(beatmapSet.Files, realm));
|
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");
|
LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PreImport(BeatmapSetInfo beatmapSet, Realm realm)
|
protected override void PreImport(BeatmapSetInfo beatmapSet, Realm realm)
|
||||||
|
@ -318,7 +318,7 @@ namespace osu.Game.Stores
|
|||||||
/// <param name="archive">An optional archive to use for model population.</param>
|
/// <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="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</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())
|
using (var realm = ContextFactory.CreateContext())
|
||||||
{
|
{
|
||||||
@ -352,7 +352,7 @@ namespace osu.Game.Stores
|
|||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return existing.ToLive(ContextFactory);
|
return Task.FromResult((ILive<TModel>?)existing.ToLive(ContextFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
|
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
|
||||||
@ -373,7 +373,7 @@ namespace osu.Game.Stores
|
|||||||
item.Hash = ComputeHash(item);
|
item.Hash = ComputeHash(item);
|
||||||
|
|
||||||
// TODO: we may want to run this outside of the transaction.
|
// 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)
|
if (!checkedExisting)
|
||||||
existing = CheckForExisting(item, realm);
|
existing = CheckForExisting(item, realm);
|
||||||
@ -387,7 +387,7 @@ namespace osu.Game.Stores
|
|||||||
existing.DeletePending = false;
|
existing.DeletePending = false;
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
|
|
||||||
return existing.ToLive(ContextFactory);
|
return Task.FromResult((ILive<TModel>?)existing.ToLive(ContextFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogForModel(item, @"Found existing but failed re-use check.");
|
LogForModel(item, @"Found existing but failed re-use check.");
|
||||||
@ -413,7 +413,7 @@ namespace osu.Game.Stores
|
|||||||
throw;
|
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="archive">The archive to use as a reference for population. May be null.</param>
|
||||||
/// <param name="realm">The current realm context.</param>
|
/// <param name="realm">The current realm context.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</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>
|
/// <summary>
|
||||||
/// Perform any final actions before the import to database executes.
|
/// Perform any final actions before the import to database executes.
|
||||||
|
Loading…
Reference in New Issue
Block a user