1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Fix legacy beatmap importer not always handling nested paths correctly

Addresses https://github.com/ppy/osu/discussions/24989.
This commit is contained in:
Dean Herbert 2023-10-03 16:01:15 +09:00
parent 09c9baadec
commit b234a453da
2 changed files with 9 additions and 4 deletions

View File

@ -44,17 +44,23 @@ namespace osu.Game.Tests.Database
createFile(subdirectory2, Path.Combine("beatmap5", "beatmap.osu"));
createFile(subdirectory2, Path.Combine("beatmap6", "beatmap.osu"));
// songs subdirectory with random file
var subdirectory3 = songsStorage.GetStorageForDirectory("subdirectory3");
createFile(subdirectory3, "silly readme.txt");
createFile(subdirectory3, Path.Combine("beatmap7", "beatmap.osu"));
// empty songs subdirectory
songsStorage.GetStorageForDirectory("subdirectory3");
string[] paths = importer.GetStableImportPaths(songsStorage).ToArray();
Assert.That(paths.Length, Is.EqualTo(6));
Assert.That(paths.Length, Is.EqualTo(7));
Assert.That(paths.Contains(songsStorage.GetFullPath("beatmap1")));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "beatmap2"))));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "beatmap3"))));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory", "sub-subdirectory", "beatmap4"))));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap5"))));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory2", "beatmap6"))));
Assert.That(paths.Contains(songsStorage.GetFullPath(Path.Combine("subdirectory3", "beatmap7"))));
}
static void createFile(Storage storage, string path)

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
@ -34,9 +33,9 @@ namespace osu.Game.Database
try
{
if (!directoryStorage.GetFiles(string.Empty).ExcludeSystemFileNames().Any())
if (!directoryStorage.GetFiles(string.Empty, "*.osu").Any())
{
// if a directory doesn't contain files, attempt looking for beatmaps inside of that directory.
// if a directory doesn't contain any beatmap files, look for further nested beatmap directories.
// this is a special behaviour in stable for beatmaps only, see https://github.com/ppy/osu/issues/18615.
foreach (string subDirectory in GetStableImportPaths(directoryStorage))
paths.Add(subDirectory);