mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Fix potential crash during stable install migration due to multiple configuration files
Apparently this can be a thing on windows. Closes https://github.com/ppy/osu/discussions/16689.
This commit is contained in:
parent
8883505eed
commit
b2ebcabdd5
@ -34,11 +34,17 @@ namespace osu.Game.IO
|
||||
|
||||
private string locateSongsDirectory()
|
||||
{
|
||||
string configFile = GetFiles(".", $"osu!.{Environment.UserName}.cfg").SingleOrDefault();
|
||||
var configurationFiles = GetFiles(".", $"osu!.{Environment.UserName}.cfg");
|
||||
|
||||
if (configFile != null)
|
||||
// GetFiles returns case insensitive results, so multiple files could exist.
|
||||
// Prefer a case-correct match, but fallback to any available.
|
||||
string usableConfigFile =
|
||||
configurationFiles.FirstOrDefault(f => f.Contains(Environment.UserName, StringComparison.Ordinal))
|
||||
?? configurationFiles.FirstOrDefault();
|
||||
|
||||
if (usableConfigFile != null)
|
||||
{
|
||||
using (var stream = GetStream(configFile))
|
||||
using (var stream = GetStream(usableConfigFile))
|
||||
using (var textReader = new StreamReader(stream))
|
||||
{
|
||||
string line;
|
||||
|
Loading…
Reference in New Issue
Block a user