mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 02:02:55 +08:00
Improve missing beatmap failure logging on score import
This commit is contained in:
parent
09b04e3cdd
commit
f216d7264b
@ -8,6 +8,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
@ -46,10 +47,12 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
score.ScoreInfo = scoreInfo;
|
score.ScoreInfo = scoreInfo;
|
||||||
|
|
||||||
int version = sr.ReadInt32();
|
int version = sr.ReadInt32();
|
||||||
|
string beatmapHash = sr.ReadString();
|
||||||
|
|
||||||
|
workingBeatmap = GetBeatmap(beatmapHash);
|
||||||
|
|
||||||
workingBeatmap = GetBeatmap(sr.ReadString());
|
|
||||||
if (workingBeatmap is DummyWorkingBeatmap)
|
if (workingBeatmap is DummyWorkingBeatmap)
|
||||||
throw new BeatmapNotFoundException();
|
throw new BeatmapNotFoundException(beatmapHash);
|
||||||
|
|
||||||
scoreInfo.User = new APIUser { Username = sr.ReadString() };
|
scoreInfo.User = new APIUser { Username = sr.ReadString() };
|
||||||
|
|
||||||
@ -334,9 +337,11 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
|
|
||||||
public class BeatmapNotFoundException : Exception
|
public class BeatmapNotFoundException : Exception
|
||||||
{
|
{
|
||||||
public BeatmapNotFoundException()
|
public string Hash { get; }
|
||||||
: base("No corresponding beatmap for the score could be found.")
|
|
||||||
|
public BeatmapNotFoundException(string hash)
|
||||||
{
|
{
|
||||||
|
Hash = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -17,6 +18,7 @@ using osu.Game.Scoring.Legacy;
|
|||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using Realms;
|
using Realms;
|
||||||
@ -44,7 +46,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
protected override ScoreInfo? CreateModel(ArchiveReader archive)
|
protected override ScoreInfo? CreateModel(ArchiveReader archive)
|
||||||
{
|
{
|
||||||
using (var stream = archive.GetStream(archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase))))
|
string name = archive.Filenames.First(f => f.EndsWith(".osr", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
using (var stream = archive.GetStream(name))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -52,7 +56,9 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
catch (LegacyScoreDecoder.BeatmapNotFoundException e)
|
catch (LegacyScoreDecoder.BeatmapNotFoundException e)
|
||||||
{
|
{
|
||||||
Logger.Log(e.Message, LoggingTarget.Information, LogLevel.Error);
|
Logger.Log($@"Score '{name}' failed to import: no corresponding beatmap with the hash '{e.Hash}' could be found.", LoggingTarget.Database);
|
||||||
|
Logger.Log($@"Score '{name}' failed to import due to missing beatmap. Check database logs for more info.", LoggingTarget.Information, LogLevel.Error);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user