From 18368d2446ff66e6647cebf368efa3a68057e8fc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Mar 2018 20:15:17 +0900 Subject: [PATCH 1/5] Make import notifications fail when any imports fail --- osu.Game/Database/ArchiveModelManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index a65593ff82..dac38b2405 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -88,7 +88,8 @@ namespace osu.Game.Database List imported = new List(); - int i = 0; + int success = 0; + int errors = 0; foreach (string path in paths) { if (notification.State == ProgressNotificationState.Cancelled) @@ -97,11 +98,11 @@ namespace osu.Game.Database try { - notification.Text = $"Importing ({i} of {paths.Length})\n{Path.GetFileName(path)}"; + notification.Text = $"Importing ({success} of {paths.Length})\n{Path.GetFileName(path)}"; using (ArchiveReader reader = getReaderFrom(path)) imported.Add(Import(reader)); - notification.Progress = (float)++i / paths.Length; + notification.Progress = (float)++success / paths.Length; // We may or may not want to delete the file depending on where it is stored. // e.g. reconstructing/repairing database with items from default storage. @@ -121,10 +122,11 @@ namespace osu.Game.Database { e = e.InnerException ?? e; Logger.Error(e, $@"Could not import ({Path.GetFileName(path)})"); + errors++; } } - notification.State = ProgressNotificationState.Completed; + notification.State = errors == 0 ? ProgressNotificationState.Completed : ProgressNotificationState.Cancelled; } /// From 994c7bfabdaed12ceebc16959a3c7157c43a99a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Mar 2018 20:30:45 +0900 Subject: [PATCH 2/5] Further improvements to messaging --- osu.Game/Database/ArchiveModelManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index dac38b2405..bdc7c58238 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -79,7 +79,6 @@ namespace osu.Game.Database var notification = new ProgressNotification { Text = "Import is initialising...", - CompletionText = "Import successful!", Progress = 0, State = ProgressNotificationState.Active, }; @@ -88,7 +87,7 @@ namespace osu.Game.Database List imported = new List(); - int success = 0; + int current = 0; int errors = 0; foreach (string path in paths) { @@ -98,11 +97,11 @@ namespace osu.Game.Database try { - notification.Text = $"Importing ({success} of {paths.Length})\n{Path.GetFileName(path)}"; + notification.Text = $"Importing ({++current} of {paths.Length})\n{Path.GetFileName(path)}"; using (ArchiveReader reader = getReaderFrom(path)) imported.Add(Import(reader)); - notification.Progress = (float)++success / paths.Length; + notification.Progress = (float)(current - 1) / paths.Length; // We may or may not want to delete the file depending on where it is stored. // e.g. reconstructing/repairing database with items from default storage. @@ -126,7 +125,8 @@ namespace osu.Game.Database } } - notification.State = errors == 0 ? ProgressNotificationState.Completed : ProgressNotificationState.Cancelled; + notification.Text = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!"; + notification.State = ProgressNotificationState.Completed; } /// @@ -333,7 +333,7 @@ namespace osu.Game.Database { if (ZipFile.IsZipFile(path)) return new ZipArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path)); - return new LegacyFilesystemReader(path); + return new LegacyFilesystemReader(path); } } } From 625e561fc8a5b0a35c92908b74eb290fee348efc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 20 Mar 2018 18:01:09 +0900 Subject: [PATCH 3/5] Fix whitespace --- osu.Game/Database/ArchiveModelManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index bdc7c58238..78bf46eb69 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -333,7 +333,7 @@ namespace osu.Game.Database { if (ZipFile.IsZipFile(path)) return new ZipArchiveReader(Files.Storage.GetStream(path), Path.GetFileName(path)); - return new LegacyFilesystemReader(path); + return new LegacyFilesystemReader(path); } } } From 101caf3064de36bf379f59adacdc102e54744935 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Mar 2018 11:28:40 +0900 Subject: [PATCH 4/5] Apply same logic fixes to delete/restore all notifications --- osu.Game/Database/ArchiveModelManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 78bf46eb69..f781beb443 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -220,8 +220,8 @@ namespace osu.Game.Database // user requested abort return; - notification.Text = $"Deleting ({i} of {items.Count})"; - notification.Progress = (float)++i / items.Count; + notification.Progress = (float)i / items.Count; + notification.Text = $"Deleting ({++i} of {items.Count})"; Delete(b); } } @@ -256,8 +256,8 @@ namespace osu.Game.Database // user requested abort return; - notification.Text = $"Restoring ({i} of {items.Count})"; - notification.Progress = (float)++i / items.Count; + notification.Progress = (float)i / items.Count; + notification.Text = $"Restoring ({++i} of {items.Count})"; Undelete(item); } } From dc9fb84e254550c0069d61a7137f80ba96bb10d8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 22 Mar 2018 14:46:25 +0900 Subject: [PATCH 5/5] Update progress with the current item, not the next item In the case where there is no next item, the progress will not get updated, so we'll essentially skip one element from filling the progress bar further. In the future we may/will want to not hide the notification upon completion, so this will look better in such scenarios. --- osu.Game/Database/ArchiveModelManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index f781beb443..ef85f691d6 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -101,7 +101,7 @@ namespace osu.Game.Database using (ArchiveReader reader = getReaderFrom(path)) imported.Add(Import(reader)); - notification.Progress = (float)(current - 1) / paths.Length; + notification.Progress = (float)current / paths.Length; // We may or may not want to delete the file depending on where it is stored. // e.g. reconstructing/repairing database with items from default storage. @@ -220,9 +220,11 @@ namespace osu.Game.Database // user requested abort return; - notification.Progress = (float)i / items.Count; notification.Text = $"Deleting ({++i} of {items.Count})"; + Delete(b); + + notification.Progress = (float)i / items.Count; } } @@ -256,9 +258,11 @@ namespace osu.Game.Database // user requested abort return; - notification.Progress = (float)i / items.Count; notification.Text = $"Restoring ({++i} of {items.Count})"; + Undelete(item); + + notification.Progress = (float)i / items.Count; } }