mirror of https://github.com/ppy/osu
Don't import replays with no existing beatmap
This commit is contained in:
parent
554c858944
commit
2bb7a078c9
|
@ -37,7 +37,11 @@ public Score Parse(Stream stream)
|
|||
|
||||
var version = sr.ReadInt32();
|
||||
|
||||
currentBeatmap = GetBeatmap(sr.ReadString()).Beatmap;
|
||||
var workingBeatmap = GetBeatmap(sr.ReadString());
|
||||
if (workingBeatmap is DummyWorkingBeatmap)
|
||||
throw new BeatmapNotFoundException();
|
||||
|
||||
currentBeatmap = workingBeatmap.Beatmap;
|
||||
score.ScoreInfo.BeatmapInfo = currentBeatmap.BeatmapInfo;
|
||||
|
||||
score.ScoreInfo.User = score.Replay.User = new User { Username = sr.ReadString() };
|
||||
|
@ -185,5 +189,13 @@ private ReplayFrame convertFrame(LegacyReplayFrame legacyFrame)
|
|||
/// <param name="md5Hash">The MD5 hash.</param>
|
||||
/// <returns>The <see cref="WorkingBeatmap"/>.</returns>
|
||||
protected abstract WorkingBeatmap GetBeatmap(string md5Hash);
|
||||
|
||||
public class BeatmapNotFoundException : Exception
|
||||
{
|
||||
public BeatmapNotFoundException()
|
||||
: base("No corresponding beatmap for the score could be found.")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
|
@ -41,8 +42,18 @@ protected override ScoreInfo CreateModel(ArchiveReader archive)
|
|||
return null;
|
||||
|
||||
using (var stream = archive.GetStream(archive.Filenames.First(f => f.EndsWith(".osr"))))
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DatabasedLegacyScoreParser(rulesets, beatmaps).Parse(stream).ScoreInfo;
|
||||
}
|
||||
catch (LegacyScoreParser.BeatmapNotFoundException e)
|
||||
{
|
||||
Logger.Log(e.Message, LoggingTarget.Information, LogLevel.Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override ScoreInfo CheckForExisting(ScoreInfo model)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue