1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-11 21:42:55 +08:00

Preserve collections when saving a beatmap

This commit is contained in:
pfg 2022-10-08 12:42:29 -04:00
parent a1f96ad5f8
commit ff14453c2b

View File

@ -17,6 +17,7 @@ using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Game.Beatmaps.Formats;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO.Archives;
@ -311,6 +312,8 @@ namespace osu.Game.Beatmaps
if (existingFileInfo != null)
DeleteFile(setInfo, existingFileInfo);
string? oldMd5Hash = beatmapInfo.MD5Hash;
beatmapInfo.MD5Hash = stream.ComputeMD5Hash();
beatmapInfo.Hash = stream.ComputeSHA2Hash();
@ -327,6 +330,12 @@ namespace osu.Game.Beatmaps
setInfo.CopyChangesToRealm(liveBeatmapSet);
foreach (var collection in r.All<BeatmapCollection>())
{
if (collection.BeatmapMD5Hashes.Remove(oldMd5Hash))
collection.BeatmapMD5Hashes.Add(beatmapInfo.MD5Hash);
}
ProcessBeatmap?.Invoke((liveBeatmapSet, false));
});
}