1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +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)
{
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))
await importer.Import(tasks);
var importList = tasks.Where(t => t.Path.EndsWith(extension, StringComparison.OrdinalIgnoreCase));
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);