Merge pull request #22105 from frenzibyte/improve-score-import-logging

Improve missing beatmap failure logging on score import
This commit is contained in:
Dean Herbert
2023-01-10 22:28:38 +09:00
committed by GitHub
3 changed files with 18 additions and 9 deletions

View File

@ -154,9 +154,12 @@ namespace osu.Game.Database
} }
else else
{ {
notification.CompletionText = imported.Count == 1 if (tasks.Length > imported.Count)
? $"Imported {imported.First().GetDisplayString()}!" notification.CompletionText = $"Imported {imported.Count} of {tasks.Length} {HumanisedModelName}s.";
: $"Imported {imported.Count} {HumanisedModelName}s!"; else if (imported.Count > 1)
notification.CompletionText = $"Imported {imported.Count} {HumanisedModelName}s!";
else
notification.CompletionText = $"Imported {imported.First().GetDisplayString()}!";
if (imported.Count > 0 && PresentImport != null) if (imported.Count > 0 && PresentImport != null)
{ {

View File

@ -46,10 +46,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 +336,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;
} }
} }
} }

View File

@ -44,7 +44,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 +54,7 @@ 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);
return null; return null;
} }
} }