1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Merge pull request #22467 from Cootz/issue#22345

Fix migration putting game files in root of disk if no other files exist
This commit is contained in:
Dean Herbert 2023-01-31 18:41:34 +09:00 committed by GitHub
commit 7d1b5751fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
var directoryInfos = target.GetDirectories();
var fileInfos = target.GetFiles();
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))
@ -65,7 +65,9 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
return;
}
target = target.CreateSubdirectory("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)