mirror of
https://github.com/ppy/osu
synced 2025-01-11 08:39:31 +00:00
Add safety against calling GetStableImportPaths
when path doesn't exist
This commit is contained in:
parent
adc7b61240
commit
30fdbc3de0
@ -24,8 +24,14 @@ namespace osu.Game.Database
|
||||
/// <summary>
|
||||
/// Select paths to import from stable where all paths should be absolute. Default implementation iterates all directories in <see cref="ImportFromStablePath"/>.
|
||||
/// </summary>
|
||||
protected virtual IEnumerable<string> GetStableImportPaths(Storage storage) => storage.GetDirectories(ImportFromStablePath)
|
||||
.Select(path => storage.GetFullPath(path));
|
||||
protected virtual IEnumerable<string> GetStableImportPaths(Storage storage)
|
||||
{
|
||||
if (!storage.ExistsDirectory(ImportFromStablePath))
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
return storage.GetDirectories(ImportFromStablePath)
|
||||
.Select(path => storage.GetFullPath(path));
|
||||
}
|
||||
|
||||
protected readonly IModelImporter<TModel> Importer;
|
||||
|
||||
|
@ -15,8 +15,14 @@ namespace osu.Game.Database
|
||||
protected override string ImportFromStablePath => Path.Combine("Data", "r");
|
||||
|
||||
protected override IEnumerable<string> GetStableImportPaths(Storage storage)
|
||||
=> storage.GetFiles(ImportFromStablePath).Where(p => Importer.HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.OrdinalIgnoreCase) ?? false))
|
||||
.Select(path => storage.GetFullPath(path));
|
||||
{
|
||||
if (!storage.ExistsDirectory(ImportFromStablePath))
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
return storage.GetFiles(ImportFromStablePath)
|
||||
.Where(p => Importer.HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.OrdinalIgnoreCase) ?? false))
|
||||
.Select(path => storage.GetFullPath(path));
|
||||
}
|
||||
|
||||
public LegacyScoreImporter(IModelImporter<ScoreInfo> importer)
|
||||
: base(importer)
|
||||
|
Loading…
Reference in New Issue
Block a user