mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Merge pull request #18833 from peppy/beatmap-manager-misc
Ensure `WorkingBeatmap` is always using a detached instance
This commit is contained in:
commit
a329b346a4
@ -418,22 +418,24 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#region Implementation of IWorkingBeatmapCache
|
||||
|
||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? importedBeatmap)
|
||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? beatmapInfo)
|
||||
{
|
||||
// Detached sets don't come with files.
|
||||
// If we seem to be missing files, now is a good time to re-fetch.
|
||||
if (importedBeatmap?.BeatmapSet?.Files.Count == 0)
|
||||
if (beatmapInfo?.IsManaged == true || beatmapInfo?.BeatmapSet?.Files.Count == 0)
|
||||
{
|
||||
Realm.Run(r =>
|
||||
{
|
||||
var refetch = r.Find<BeatmapInfo>(importedBeatmap.ID)?.Detach();
|
||||
var refetch = r.Find<BeatmapInfo>(beatmapInfo.ID)?.Detach();
|
||||
|
||||
if (refetch != null)
|
||||
importedBeatmap = refetch;
|
||||
beatmapInfo = refetch;
|
||||
});
|
||||
}
|
||||
|
||||
return workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
|
||||
Debug.Assert(beatmapInfo?.IsManaged != true);
|
||||
|
||||
return workingBeatmapCache.GetWorkingBeatmap(beatmapInfo);
|
||||
}
|
||||
|
||||
void IWorkingBeatmapCache.Invalidate(BeatmapSetInfo beatmapSetInfo) => workingBeatmapCache.Invalidate(beatmapSetInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user