<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.IO;

namespace osu.Game.Database
{
    public class LegacyBeatmapImporter : LegacyModelImporter<BeatmapSetInfo>
    {
        protected override string ImportFromStablePath => ".";

        protected override Storage PrepareStableStorage(StableStorage stableStorage) => stableStorage.GetSongStorage();

        public LegacyBeatmapImporter(IModelImporter<BeatmapSetInfo> importer)
            : base(importer)
        {
        }
    }
}<commit_msg>Handle subdirectories during beatmap stable import<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using System.Linq;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.IO;

namespace osu.Game.Database
{
    public class LegacyBeatmapImporter : LegacyModelImporter<BeatmapSetInfo>
    {
        protected override string ImportFromStablePath => ".";

        protected override Storage PrepareStableStorage(StableStorage stableStorage) => stableStorage.GetSongStorage();

        protected override IEnumerable<string> GetStableImportPaths(Storage storage)
        {
            foreach (string beatmapDirectory in storage.GetDirectories(string.Empty))
            {
                var beatmapStorage = storage.GetStorageForDirectory(beatmapDirectory);

                if (!beatmapStorage.GetFiles(string.Empty).ExcludeSystemFileNames().Any())
                {
                    // if a directory doesn't contain files, attempt looking for beatmaps inside of that directory.
                    // this is a special behaviour in stable for beatmaps only, see https://github.com/ppy/osu/issues/18615.
                    foreach (string beatmapInDirectory in GetStableImportPaths(beatmapStorage))
                        yield return beatmapStorage.GetFullPath(beatmapInDirectory);
                }
                else
                    yield return storage.GetFullPath(beatmapDirectory);
            }
        }

        public LegacyBeatmapImporter(IModelImporter<BeatmapSetInfo> importer)
            : base(importer)
        {
        }
    }
}
{'fraction_non_alphanumeric': 0.07670103092783505, 'fraction_numerical': 0.002061855670103093, 'mean_word_length': 2.790625, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5313828', 'n_tokens_mistral': 658, 'n_tokens_neox': 615, 'n_words': 164}