1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Check if path can be imported before trying

This commit is contained in:
HoLLy 2019-06-19 20:36:00 +02:00
parent ef2e93d5c7
commit 0cb66d522a

View File

@ -150,7 +150,7 @@ namespace osu.Game.Database
var imported = new List<TModel>(); var imported = new List<TModel>();
await Task.WhenAll(paths.Select(async path => await Task.WhenAll(paths.Where(canImportPath).Select(async path =>
{ {
notification.CancellationToken.ThrowIfCancellationRequested(); notification.CancellationToken.ThrowIfCancellationRequested();
@ -160,8 +160,7 @@ namespace osu.Game.Database
lock (imported) lock (imported)
{ {
if (model != null) imported.Add(model);
imported.Add(model);
current++; current++;
notification.Text = $"Imported {current} of {paths.Length} {HumanisedModelName}s"; notification.Text = $"Imported {current} of {paths.Length} {HumanisedModelName}s";
@ -201,6 +200,8 @@ namespace osu.Game.Database
notification.State = ProgressNotificationState.Completed; notification.State = ProgressNotificationState.Completed;
} }
bool canImportPath(string path) => StableDirectoryBased || HandledExtensions.Any(ext => Path.GetExtension(path)?.ToLowerInvariant() == ext);
} }
/// <summary> /// <summary>