From eb86f9de5e2e2db53bf756d5724f0da6ce5125f7 Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Sat, 15 Sep 2018 09:28:19 -0400 Subject: [PATCH 1/6] Check for skins folder also --- osu.Desktop/OsuGameDesktop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 79ac24a1da..9d75c49a6a 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -92,7 +92,7 @@ private class StableStorage : WindowsStorage { protected override string LocateBasePath() { - bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs")); + bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs")) && Directory.Exists(Path.Combine(p, "Skins")); string stableInstallPath; From 75e6bbc4d895987c2837846febf242be96fa7e80 Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Sat, 15 Sep 2018 09:33:31 -0400 Subject: [PATCH 2/6] Revert "Check for skins folder also" This reverts commit eb86f9de5e2e2db53bf756d5724f0da6ce5125f7. --- osu.Desktop/OsuGameDesktop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 9d75c49a6a..79ac24a1da 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -92,7 +92,7 @@ private class StableStorage : WindowsStorage { protected override string LocateBasePath() { - bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs")) && Directory.Exists(Path.Combine(p, "Skins")); + bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs")); string stableInstallPath; From 42b2c322226b6ed2c1a9ba5ba5744762adee9d0d Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Sat, 15 Sep 2018 09:47:50 -0400 Subject: [PATCH 3/6] Catch directory not found exception --- osu.Game/Database/ArchiveModelManager.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index f4f169f27c..ce0ec5caed 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -438,7 +438,15 @@ public Task ImportFromStableAsync() return Task.CompletedTask; } - return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); + return Task.Factory.StartNew(() => { + try { + Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()); + } catch (DirectoryNotFoundException) { + // This handles situations like when the user does not have a Skins folder + // which would have this exception thrown from stable.GetDirectories + Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); + } + }, TaskCreationOptions.LongRunning); } #endregion From d469748612a9034be91c0d8874610333b24b0b1f Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Sat, 15 Sep 2018 09:53:59 -0400 Subject: [PATCH 4/6] Reformat code --- 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 ce0ec5caed..ee9bf70aeb 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -438,10 +438,14 @@ public Task ImportFromStableAsync() return Task.CompletedTask; } - return Task.Factory.StartNew(() => { - try { + return Task.Factory.StartNew(() => + { + try + { Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()); - } catch (DirectoryNotFoundException) { + } + catch (DirectoryNotFoundException) + { // This handles situations like when the user does not have a Skins folder // which would have this exception thrown from stable.GetDirectories Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); From 8bfd981a50526768f0c0b17f5edc444fc4ff8cbf Mon Sep 17 00:00:00 2001 From: Paul Teng Date: Mon, 17 Sep 2018 21:05:28 -0400 Subject: [PATCH 5/6] Handle directory checking before entering task --- osu.Game/Database/ArchiveModelManager.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index ee9bf70aeb..06a8b490ef 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -438,19 +438,14 @@ public Task ImportFromStableAsync() return Task.CompletedTask; } - return Task.Factory.StartNew(() => + if (!stable.ExistsDirectory(ImportFromStablePath)) { - try - { - Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()); - } - catch (DirectoryNotFoundException) - { - // This handles situations like when the user does not have a Skins folder - // which would have this exception thrown from stable.GetDirectories - Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); - } - }, TaskCreationOptions.LongRunning); + // This handles situations like when the user does not have a Skins folder + Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); + return Task.CompletedTask; + } + + return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning); } #endregion From 293a5dd09906ed2ef73df76166e8231fc8b0dec0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Sep 2018 11:50:36 +0900 Subject: [PATCH 6/6] Use string interpolation --- osu.Game/Database/ArchiveModelManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 06a8b490ef..2a31df462e 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -96,7 +96,8 @@ private void flushEvents(bool perform) private void handleEvent(Action a) { if (delayingEvents) - lock (queuedEvents) queuedEvents.Add(a); + lock (queuedEvents) + queuedEvents.Add(a); else a.Invoke(); } @@ -441,7 +442,7 @@ public Task ImportFromStableAsync() if (!stable.ExistsDirectory(ImportFromStablePath)) { // This handles situations like when the user does not have a Skins folder - Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); + Logger.Log($"No {ImportFromStablePath} folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error); return Task.CompletedTask; }