From 54d5d4e7c6a96fb4cd1d48d8b89ad6d508e181b0 Mon Sep 17 00:00:00 2001 From: Cootz Date: Tue, 31 Jan 2023 07:06:26 +0300 Subject: [PATCH 1/3] Fix for the issue --- .../Settings/Sections/Maintenance/MigrationSelectScreen.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs index 80bf292057..57eb5ce60e 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs @@ -47,6 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance var directoryInfos = target.GetDirectories(); var fileInfos = target.GetFiles(); + //With an empty disk (mb flash drive), this if could be false if (directoryInfos.Length > 0 || fileInfos.Length > 0) { // Quick test for whether there's already an osu! install at the target path. @@ -65,7 +66,11 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance return; } - target = target.CreateSubdirectory("osu-lazer"); + //Check for a root directory + if (target.Parent == null) + target = Directory.CreateDirectory(Path.Combine(target.FullName, "osu-lazer")); + else + target = target.CreateSubdirectory("osu-lazer"); } } catch (Exception e) From b18652b25fa366ea9191db55af53b43fc02fcb30 Mon Sep 17 00:00:00 2001 From: Cootz Date: Tue, 31 Jan 2023 10:14:21 +0300 Subject: [PATCH 2/3] CreateSubDirectory removed. Fixes the empty root issue --- .../Sections/Maintenance/MigrationSelectScreen.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs index 57eb5ce60e..159a99809d 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs @@ -47,8 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance var directoryInfos = target.GetDirectories(); var fileInfos = target.GetFiles(); - //With an empty disk (mb flash drive), this if could be false - if (directoryInfos.Length > 0 || fileInfos.Length > 0) + if (directoryInfos.Length > 0 || fileInfos.Length > 0 || target.Parent == null) { // Quick test for whether there's already an osu! install at the target path. if (fileInfos.Any(f => f.Name == OsuGameBase.CLIENT_DATABASE_FILENAME)) @@ -66,11 +65,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance return; } - //Check for a root directory - if (target.Parent == null) - target = Directory.CreateDirectory(Path.Combine(target.FullName, "osu-lazer")); - else - target = target.CreateSubdirectory("osu-lazer"); + //We aren't using CreateSubDirectory due to the flaw with a root of a drive + target = Directory.CreateDirectory(Path.Combine(target.FullName, "osu-lazer")); } } catch (Exception e) From 5d22f3d879add77336918409203e0955a4bff2ab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Jan 2023 17:17:21 +0900 Subject: [PATCH 3/3] Improve inline comment --- .../Settings/Sections/Maintenance/MigrationSelectScreen.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs index 159a99809d..309e2a1401 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs @@ -65,8 +65,9 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance return; } - //We aren't using CreateSubDirectory due to the flaw with a root of a drive - target = Directory.CreateDirectory(Path.Combine(target.FullName, "osu-lazer")); + // Not using CreateSubDirectory as it throws unexpectedly when attempting to create a directory when already at the root of a disk. + // See https://cs.github.com/dotnet/runtime/blob/f1bdd5a6182f43f3928b389b03f7bc26f826c8bc/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs#L88-L94 + target = Directory.CreateDirectory(Path.Combine(target.FullName, @"osu-lazer")); } } catch (Exception e)