mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 04:52:53 +08:00
Fix reprocessing not working on import due to realm threading woes
This commit is contained in:
parent
30b3973c9f
commit
0c3d890f76
@ -80,8 +80,6 @@ namespace osu.Game.Beatmaps
|
|||||||
// If this is ever an issue, we can consider marking as pending delete but not resetting the IDs (but care will be required for
|
// If this is ever an issue, we can consider marking as pending delete but not resetting the IDs (but care will be required for
|
||||||
// beatmaps, which don't have their own `DeletePending` state).
|
// beatmaps, which don't have their own `DeletePending` state).
|
||||||
|
|
||||||
beatmapUpdater?.Process(beatmapSet, realm);
|
|
||||||
|
|
||||||
if (beatmapSet.OnlineID > 0)
|
if (beatmapSet.OnlineID > 0)
|
||||||
{
|
{
|
||||||
var existingSetWithSameOnlineID = realm.All<BeatmapSetInfo>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID);
|
var existingSetWithSameOnlineID = realm.All<BeatmapSetInfo>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID);
|
||||||
@ -99,6 +97,13 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void PostImport(BeatmapSetInfo model, Realm realm)
|
||||||
|
{
|
||||||
|
base.PostImport(model, realm);
|
||||||
|
|
||||||
|
beatmapUpdater?.Process(model);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateOnlineIds(BeatmapSetInfo beatmapSet, Realm realm)
|
private void validateOnlineIds(BeatmapSetInfo beatmapSet, Realm realm)
|
||||||
{
|
{
|
||||||
var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID > 0).Select(b => b.OnlineID).ToList();
|
var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID > 0).Select(b => b.OnlineID).ToList();
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using Realms;
|
using Realms;
|
||||||
@ -52,17 +52,18 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
foreach (var beatmap in beatmapSet.Beatmaps)
|
foreach (var beatmap in beatmapSet.Beatmaps)
|
||||||
{
|
{
|
||||||
// Because we aren't guaranteed all processing will happen on this thread, it's very hard to use the live realm object.
|
difficultyCache.Invalidate(beatmap);
|
||||||
// This can be fixed by adding a synchronous flow to `BeatmapDifficultyCache`.
|
|
||||||
var detachedBeatmap = beatmap.Detach();
|
|
||||||
|
|
||||||
beatmap.StarRating = difficultyCache.GetDifficultyAsync(detachedBeatmap).GetResultSafely()?.Stars ?? 0;
|
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap.Detach());
|
||||||
|
var ruleset = working.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
|
|
||||||
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap);
|
Debug.Assert(ruleset != null);
|
||||||
|
|
||||||
|
var calculator = ruleset.CreateDifficultyCalculator(working);
|
||||||
|
|
||||||
|
beatmap.StarRating = calculator.Calculate().StarRating;
|
||||||
beatmap.Length = calculateLength(working.Beatmap);
|
beatmap.Length = calculateLength(working.Beatmap);
|
||||||
beatmap.BPM = 60000 / working.Beatmap.GetMostCommonBeatLength();
|
beatmap.BPM = 60000 / working.Beatmap.GetMostCommonBeatLength();
|
||||||
|
|
||||||
difficultyCache.Invalidate(beatmap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user