Fix error notification

This commit is contained in:
Dean Herbert 2018-09-07 18:14:23 +09:00
parent 81da7ce298
commit 168dbe9329

View File

@ -130,7 +130,6 @@ namespace osu.Game.Database
List<TModel> imported = new List<TModel>(); List<TModel> imported = new List<TModel>();
int current = 0; int current = 0;
int errors = 0;
foreach (string path in paths) foreach (string path in paths)
{ {
if (notification.State == ProgressNotificationState.Cancelled) if (notification.State == ProgressNotificationState.Cancelled)
@ -163,14 +162,20 @@ namespace osu.Game.Database
{ {
e = e.InnerException ?? e; e = e.InnerException ?? e;
Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})");
errors++;
} }
} }
notification.Text = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!"; if (imported.Count == 0)
{
notification.Text = "Import failed!";
notification.State = ProgressNotificationState.Cancelled;
}
else
{
notification.CompletionText = $"Imported {current} {typeof(TModel).Name.Replace("Info", "").ToLower()}s!"; notification.CompletionText = $"Imported {current} {typeof(TModel).Name.Replace("Info", "").ToLower()}s!";
notification.State = ProgressNotificationState.Completed; notification.State = ProgressNotificationState.Completed;
} }
}
/// <summary> /// <summary>
/// Import an item from an <see cref="ArchiveReader"/>. /// Import an item from an <see cref="ArchiveReader"/>.