diff --git a/osu.Game/Beatmaps/WorkingBeatmapCache.cs b/osu.Game/Beatmaps/WorkingBeatmapCache.cs index 74a85cde7c..8af74d11d8 100644 --- a/osu.Game/Beatmaps/WorkingBeatmapCache.cs +++ b/osu.Game/Beatmaps/WorkingBeatmapCache.cs @@ -9,6 +9,7 @@ using System.Linq; using JetBrains.Annotations; using osu.Framework.Audio; using osu.Framework.Audio.Track; +using osu.Framework.Extensions; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Dummy; using osu.Framework.Graphics.Textures; @@ -143,8 +144,6 @@ namespace osu.Game.Beatmaps { string fileStorePath = BeatmapSetInfo.GetPathForFile(BeatmapInfo.Path); - // TODO: check validity of file - var stream = GetStream(fileStorePath); if (stream == null) @@ -153,6 +152,12 @@ namespace osu.Game.Beatmaps return null; } + if (stream.ComputeMD5Hash() != BeatmapInfo.MD5Hash) + { + Logger.Log($"Beatmap failed to load (file {BeatmapInfo.Path} does not have the expected hash).", level: LogLevel.Error); + return null; + } + using (var reader = new LineBufferedReader(stream)) return Decoder.GetDecoder(reader).Decode(reader); }