1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 02:17:46 +08:00

Handle multiple extensions in the import files.

This commit is contained in:
Lucas A 2020-12-19 22:48:39 +01:00
parent 4fba0c8e6a
commit f1aefcdf86

View File

@ -397,13 +397,18 @@ namespace osu.Game
public virtual async Task Import(params ImportTask[] tasks) public virtual async Task Import(params ImportTask[] tasks)
{ {
var extension = Path.GetExtension(tasks.First().Path).ToLowerInvariant(); var importTasks = new List<Task>();
foreach (var importer in fileImporters) foreach (var extension in tasks.Select(t => Path.GetExtension(t.Path)).Distinct())
{ {
if (importer.HandledExtensions.Contains(extension)) var importList = tasks.Where(t => t.Path.EndsWith(extension, StringComparison.OrdinalIgnoreCase));
await importer.Import(tasks); var importer = fileImporters.FirstOrDefault(i => i.HandledExtensions.Contains(extension));
if (importer != null)
importTasks.Add(importer.Import(importList.ToArray()));
} }
await Task.WhenAll(importTasks);
} }
public IEnumerable<string> HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions); public IEnumerable<string> HandledExtensions => fileImporters.SelectMany(i => i.HandledExtensions);