mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 21:07:18 +09: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>
|
/// <summary>
|
||||||
/// Select paths to import from stable where all paths should be absolute. Default implementation iterates all directories in <see cref="ImportFromStablePath"/>.
|
/// Select paths to import from stable where all paths should be absolute. Default implementation iterates all directories in <see cref="ImportFromStablePath"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual IEnumerable<string> GetStableImportPaths(Storage storage) => storage.GetDirectories(ImportFromStablePath)
|
protected virtual IEnumerable<string> GetStableImportPaths(Storage storage)
|
||||||
.Select(path => storage.GetFullPath(path));
|
{
|
||||||
|
if (!storage.ExistsDirectory(ImportFromStablePath))
|
||||||
|
return Enumerable.Empty<string>();
|
||||||
|
|
||||||
|
return storage.GetDirectories(ImportFromStablePath)
|
||||||
|
.Select(path => storage.GetFullPath(path));
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly IModelImporter<TModel> Importer;
|
protected readonly IModelImporter<TModel> Importer;
|
||||||
|
|
||||||
|
@ -15,8 +15,14 @@ namespace osu.Game.Database
|
|||||||
protected override string ImportFromStablePath => Path.Combine("Data", "r");
|
protected override string ImportFromStablePath => Path.Combine("Data", "r");
|
||||||
|
|
||||||
protected override IEnumerable<string> GetStableImportPaths(Storage storage)
|
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)
|
public LegacyScoreImporter(IModelImporter<ScoreInfo> importer)
|
||||||
: base(importer)
|
: base(importer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user