mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Catch and gracefully handle file/directory enumeration failures during stable import
Closes https://github.com/ppy/osu/issues/21214.
This commit is contained in:
parent
d90386189a
commit
adab9f0e48
@ -1,11 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
using System;
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
@ -22,22 +23,42 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
// make sure the directory exists
|
// make sure the directory exists
|
||||||
if (!storage.ExistsDirectory(string.Empty))
|
if (!storage.ExistsDirectory(string.Empty))
|
||||||
yield break;
|
return Array.Empty<string>();
|
||||||
|
|
||||||
foreach (string directory in storage.GetDirectories(string.Empty))
|
List<string> paths = new List<string>();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var directoryStorage = storage.GetStorageForDirectory(directory);
|
foreach (string directory in storage.GetDirectories(string.Empty))
|
||||||
|
|
||||||
if (!directoryStorage.GetFiles(string.Empty).ExcludeSystemFileNames().Any())
|
|
||||||
{
|
{
|
||||||
// if a directory doesn't contain files, attempt looking for beatmaps inside of that directory.
|
var directoryStorage = storage.GetStorageForDirectory(directory);
|
||||||
// this is a special behaviour in stable for beatmaps only, see https://github.com/ppy/osu/issues/18615.
|
|
||||||
foreach (string subDirectory in GetStableImportPaths(directoryStorage))
|
try
|
||||||
yield return subDirectory;
|
{
|
||||||
|
if (!directoryStorage.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 subDirectory in GetStableImportPaths(directoryStorage))
|
||||||
|
paths.Add(subDirectory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
paths.Add(storage.GetFullPath(directory));
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
// Catch any errors when enumerating files
|
||||||
|
Logger.Log($"Error when enumerating files in {directoryStorage.GetFullPath(string.Empty)}: {e}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
yield return storage.GetFullPath(directory);
|
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
// Catch any errors when enumerating directories
|
||||||
|
Logger.Log($"Error when enumerating directories in {storage.GetFullPath(string.Empty)}: {e}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyBeatmapImporter(IModelImporter<BeatmapSetInfo> importer)
|
public LegacyBeatmapImporter(IModelImporter<BeatmapSetInfo> importer)
|
||||||
|
Loading…
Reference in New Issue
Block a user