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

Merge pull request #3310 from smoogipoo/reduce-import-noise

Softly handle errors when no beatmap file exists in archive
This commit is contained in:
Dean Herbert 2018-08-25 15:53:24 +09:00 committed by GitHub
commit df18508bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -352,9 +352,8 @@ namespace osu.Game.Beatmaps
string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu")); string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu"));
if (string.IsNullOrEmpty(mapName)) if (string.IsNullOrEmpty(mapName))
{ {
// Todo: This is temporary for debugging purposes Logger.Log($"No beatmap files found in the beatmap archive ({reader.Name}).", LoggingTarget.Database);
var files = reader.Filenames.ToList(); return null;
throw new InvalidOperationException($"No beatmap files found in this beatmap archive. Files ({files.Count}): {string.Join(", ", files)}");
} }
Beatmap beatmap; Beatmap beatmap;

View File

@ -178,7 +178,8 @@ namespace osu.Game.Database
{ {
try try
{ {
return Import(CreateModel(archive), archive); var model = CreateModel(archive);
return model == null ? null : Import(model, archive);
} }
catch (Exception e) catch (Exception e)
{ {
@ -389,7 +390,7 @@ namespace osu.Game.Database
/// Actual expensive population should be done in <see cref="Populate"/>; this should just prepare for duplicate checking. /// Actual expensive population should be done in <see cref="Populate"/>; this should just prepare for duplicate checking.
/// </summary> /// </summary>
/// <param name="archive">The archive to create the model for.</param> /// <param name="archive">The archive to create the model for.</param>
/// <returns>A model populated with minimal information.</returns> /// <returns>A model populated with minimal information. Returning a null will abort importing silently.</returns>
protected abstract TModel CreateModel(ArchiveReader archive); protected abstract TModel CreateModel(ArchiveReader archive);
/// <summary> /// <summary>